列の1つが日付列である動的JQGridがあります。 URLと日付を持つフィードからデータを取得します。日付とハイパーリンクがNAN/NAN/NANと表示されるようにJqGrid列モーダルを表示
"日付列"の列モデルを作成し、日付とハイパーリンクを表示する必要があります。しかし残念ながら、データはNAN/NAN/NANとして表示されます(これは、文字列全体を "20/8/2016"ではなく、日付として<a>...</a>
と扱っている可能性があります)。どの人がNANではなく正しいテキストで日付をここに表示することができますか?
注:私も作るべき必ず日付のソートが作業ある
サンプルコードスニペット維持されていること - がある場合 -を働いていないありなしアンカータグ & をa アンカータグ。ただし、アンカータグとは無関係に、これは常に列のモーダルがテキスト型である場合に機能します。つまり、これは日付列でのみ発生し、他の列では発生しません。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css" rel="stylesheet" />
<link href="http://trirand.com/blog/jqgrid/themes/ui.jqgrid.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://trirand.com/blog/jqgrid/js/jquery.jqGrid.min.js"></script>
<script src="http://trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var data = [{ 'Date': "<a href=https://google.com target=_blank style=text-decoration:underline;>20/8/2016</a>" },
{ 'Date': "<a href=https://google.com target=_blank style=text-decoration:underline;>21/8/2016</a>" },
{ 'Date': "<a href=https://google.com target=_blank style=text-decoration:underline;>22/8/2016</a>" },
{ 'Date': "2016-08-09T06:11:14.907Z" }, { 'Date': "2016-08-10T06:11:14.907Z" }
]
$("#grid").jqGrid({
datatype: 'jsonstring',
datastr: data,
colNames: ["Date"],
colModel: [{ name: 'Date', sorttype: 'date', formatter: 'date', formatoptions: {newformat:'n/j/Y'} }]
});
});
</script>
</head>
<body>
<table id="grid"></table>
</body>
</html>
'フォーマッタ:「[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)で入力されたデータを期待date''デフォルトでは代わりにHTMLフラグメントを使用することはできません。日付をリンク( '')として書式設定する必要がある場合は、入力データにISO 8601を使用できますが、[custom formater](http://www.trirand.com/jqgridwiki/doku.php?id= wiki:custom_formatter)を使用してデータをリンクとしてフォーマットします。 jqGridについては、使用するjqGridのバージョンとjqGrid([free jqGrid](https://github.com/free-jqgrid/jqGrid))の商用Guriddo jqGrid JSまたはalq jqGridのバージョン<= 4.7)。 – Oleg