尽管有唯一的id,jqgrid重复行

时间:2013-05-12 19:55:19

标签: javascript json jquery jqgrid

问题: 我从服务器发送10行(假设jqgrid每次请求10行)。

第一次获取:发送/显示10行(id:1到10)查看1 - 10 of 25 in grid

第二次获取:发送/显示10行(id:11到20)查看11 - 20 of 25 in grid

第3次获取:发送5行/显示10行(id:21到25,再次是21到25)查看21 - 30 of 25 in grid

属性集(来自业务层):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中定义为key。同样对于第三次获取我请求10行但从服务器接收5行。网格不应该显示5而不是重复行,因为我设置了repeatitems:false。此外,我将json数据发送回去显示时设置了记录= 25。这不是说总记录= 25.为什么它的显示视图21-30的25 ???

请帮忙......

1 个答案:

答案 0 :(得分:0)

抱歉,但我无法重现您所描述的问题。 The demo显示正确的结果

enter image description here