Issue: I am sending 10 rows from server(lets assume jqgrid requests 10 rows each time).
1st fetch : 10 rows sent/displayed (id:1 to 10) View 1 - 10 of 25 in grid
2nd fetch : 10 rows sent/displayed (id:11 to 20) View 11 - 20 of 25 in grid
3rd fetch : 5 rows sent/10 rows displayed (id:21 to 25 and again 21 to 25) View 21 - 30 of 25 in grid
Attributes Set(from business layer): 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'
});
});
below is the json data :
{"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}
NOTE : invid contains unique value in all rows, so defined as key in colModel. Also for the 3rd fetch I ma requesting 10 rows but receiving 5 from the server. Shouldn't the grid display 5 and not repeat rows as i had set repeatitems : false. Also i had set records=25 while sending json data back for display. Doesn't it mean that total records = 25. Why its showing View 21-30 of 25???
Please help...