問題: サーバーから 10 行を送信しています (jqgrid が毎回 10 行を要求すると仮定します)。
1st fetch : 送信/表示された 10 行 (id:1 から 10) グリッドで 25 の 1 - 10 を表示
2nd fetch : 送信/表示された 10 行 (id:11 から 20) グリッドで 25 の 11 - 20 を表示
3 回目のフェッチ : 送信された 5 行/表示された 10 行 (id:21 から 25 および再び 21 から 25) グリッドで 25 の 21 - 30 を表示
属性セット (ビジネス層から): page=3、records=25
JavaScript :
<script type="text/javascript">
$(function() {
$("#list").jqGrid({
url : contextPath + "/getEntities",
datatype : 'json',
mtype : 'GET',
jsonReader : {
root : "response",
page : "page",
total : "total",
records : "records",
repeatitems : false
},
colNames : [ 'Inv No', 'Date', 'Amount', 'Tax', 'Total', 'Notes' ],
colModel : [ {
name : 'invid',
width : 55,
index : 'invid',
sortable : true,
sorttype : 'text',
key : true
}, {
name : 'invdate',
index : 'invdate',
width : 90,
sorttype : 'date',
sortable : true
}, {
name : 'amount',
index : 'amount',
width : 80,
align : 'right'
}, {
name : 'tax',
index : 'tax',
width : 80,
align : 'right'
}, {
name : 'total',
index : 'total',
width : 80,
align : 'right'
}, {
name : 'note',
index : 'note',
width : 150,
sortable : false
} ],
pager : '#pager',
rowNum : 10,
rowList : [ 10, 20, 30 ],
sortname : 'invid',
sortorder : 'desc',
viewrecords : true,
gridview : true,
caption : 'My first grid'
});
});
以下はjsonデータです:
{"total":3,
"response":[
{"total":"490","amount":"500","invdate":"12-12-12","invid":"21","tax":"10","note":"OK"},
{"total":"490","amount":"500","invdate":"12-12-12","invid":"22","tax":"10","note":"OK"},
{"total":"490","amount":"500","invdate":"12-12-12","invid":"23","tax":"10","note":"OK"},
{"total":"490","amount":"500","invdate":"12-12-12","invid":"24","tax":"10","note":"OK"},
{"total":"490","amount":"500","invdate":"12-12-12","invid":"25","tax":"10","note":"OK"}],
"page":3,
"records":25}
注 : invid にはすべての行に一意の値が含まれているため、colModel でキーとして定義されます。また、3 回目のフェッチでは、10 行を要求しましたが、サーバーから 5 行を受け取りました。グリッドに 5 を表示して、repeatitems : false を設定したように行を繰り返さないでください。また、jsonデータを表示用に送り返すときに、records = 25を設定しました。合計レコード = 25 という意味ではありませんか?
助けてください...