0

日付と数値を扱うフォーマッターがあります。リンクのフォーマッタが何らかの理由で途中までしか機能していません。グリッドに表示されるのは、次のようなリンクだけです。

?id=1

URL で baseLinkUrl 設定が使用されていない (または含まれていない)。

これが私のJavaScriptです:

$(function () {
    $("#d5d02a55-ba5e-46f2-a64a-05fd7870b273_list")
        .jqGrid({
        url: '/jqgrid2/getDataJson',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Inv No', 'Date', 'Amount', 'Tax', 'Total', 'Notes'],
        colModel: [{
                "name": "invid",
                "index": "invid",
                "width": 55,
                "formatter": "showlink",
                "formatteroptions": {
                    "baseLinkUrl": "jsp/samplePage.jsp",
                    "target": "_blank",
                    "idName": "invid"
                }
            }, {
                "name": "invdate",
                "index": "invdate",
                "width": 90,
                "formatter": "date",
                "formatteroptions": {
                    "srcformat": "yyyy-MM-dd",
                    "newformat": "MM/dd/yyyy"
                }
            }, {
                "name": "amount",
                "index": "amount",
                "width": 80,
                "align": "RIGHT",
                "formatter": "number",
                "formatteroptions": {
                    "decimalPlaces": 2
                }
            }, {
                "name": "tax",
                "index": "tax",
                "width": 80,
                "align": "RIGHT",
                "formatter": "number",
                "formatteroptions": {
                    "decimalPlaces": 2
                }
            }, {
                "name": "total",
                "index": "total",
                "width": 80,
                "align": "RIGHT",
                "formatter": "number",
                "formatteroptions": {
                    "decimalPlaces": 2
                }
            }, {
                "name": "note",
                "index": "note",
                "width": 150,
                "sortable": false
            }
        ],
        pager: '#d5d02a55-ba5e-46f2-a64a-05fd7870b273_pager',
        rowNum: 5,
        rowList: [5, 10, 25, 50],
        sortname: 'invid',
        sortorder: 'asc',
        viewrecords: true,
        multiselect: false,
        gridview: true,
        caption: '',
        height: 'auto',
        jsonReader: {
            root: 'data',
            page: 'currentPage',
            total: 'totalPages',
            records: 'totalRecords',
            repeatitems: false,
            id: 'id'
        }
    });
});

そして私のデータ:

{ "currentPage" : "1",
  "data" : [ { "amount" : 1000.0,
        "invdate" : "2013-04-01 00:00:00",
        "invid" : 1,
        "note" : "No notes",
        "tax" : 60.0,
        "total" : 1060.0
      },
      { "amount" : 200.0,
        "invdate" : "2013-04-02 00:00:00",
        "invid" : 2,
        "note" : "",
        "tax" : 12.0,
        "total" : 212.0
      },
      { "amount" : 500.0,
        "invdate" : "2013-04-03 00:00:00",
        "invid" : 3,
        "note" : "",
        "tax" : 30.0,
        "total" : 530.0
      },
      { "amount" : 400.0,
        "invdate" : "2013-04-03 00:00:00",
        "invid" : 4,
        "note" : "Some notes",
        "tax" : 24.0,
        "total" : 424.0
      },
      { "amount" : 200.0,
        "invdate" : "2013-04-04 00:00:00",
        "invid" : 5,
        "note" : "",
        "tax" : 12.0,
        "total" : 2012.0
      }
    ],
  "limitRows" : "5",
  "totalPages" : "3",
  "totalRows" : "11"
}
4

1 に答える 1

1

"id"サーバーを返すデータにはプロパティが含まれていません。列がグリッドでinvid役割を果たす場合は、最初にtoと seconds を変更して(一般的には代替手段ですが、両方を使用することをお勧めします) 、列の定義にプロパティを追加する必要があります。idid: 'id'jsonReaderid: 'invid'key: trueinvid

次の重要な問題:formatteroptionsの代わりにを使用しますformatoptions。したがって、使用するほとんどの設定は無視されます。

formatoptionsもう 1 つの問題: of に間違った値を使用していますformatter: "date"。jqGrid にデータを PHP 形式で提供する必要があります。ここでは、より一般的に説明されています。開くとgrid.locale-en.js(ここを参照)、使用日の例と役立つリンクがいくつか見つかります。

于 2013-04-29T17:17:24.833 に答える