0

jquery グリッドで spring mvc を使用しています。行に日付フィールドがあります。Jsonでは、日付を次のように取得します

「リリース日」:1406399400000

ただし、表では「NaN/NaN/NaN」と表示されます。私のBeanクラスでは、Java Date形式として保持しています。グリッド構成の列モデルは次のとおりです。

colModel:[
               {name:'name', label: 'Product Name', width: 300},

               {name:'releaseDate', label: 'Release Date',formatter:'date',formatoptions: {newformat:'m/d/Y'}, width: 300}

           ],

jqgrid 4.6 を使用しています。どんな助けでも本当に感謝しています。

ありがとう!

4

1 に答える 1

0

たとえば、 のプロパティで呼び出すカスタム フォーマッタを使用formatter: "date"できsrcformat: "u"ますformatoptions。次のようなものを試してください

{
    name: 'releaseDate',
    label: 'Release Date',
    formatoptions: {newformat:'m/d/Y'},
    formatter: function (value, options) {
        if (typeof value === "number" && value > 1000000000000) {
            return $.fn.fmatter.call(this, "date", value/1000, options);
        } else {
            return " ";
        }
    },
    width: 300
}

文字列入力値の場合は、 を使用できますparseInt。おそらく、unformatsorttypeas function も提供する必要があります。

于 2014-08-01T20:49:20.590 に答える