jqGrid只显示10行

nun*_*unu 0 jquery json filtering jqgrid

由于我是jqGrid中的新手,我对此问题非常困惑.我的数据只显示10行.这是我的剧本;

jQuery("#list").jqGrid({
    url:'dounfinish.php?q=1',
    datatype: 'json',
    mtype: 'POST',
    closeafteredit:true,
    colNames:['id','Date', 'Line','Model','Lotno','Qty','PIC'],
    colModel :[ 
            {name:'id', index:'id', hidden:true, width:55}, 
            {name:'Date', index:'Date', width:90, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}}, 
            {name:'Line', index:'Line', width:80, editable:true, search:true, stype:'text',searchoptions:{sopt:['cn']}},
            {name:'Model', index:'Model', width:180, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}},
            {name:'Lotno', index:'Lotno', width:80, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}}, 
            {name:'Qty', index:'Qty', width:80, editable:true, search:true, stype:'text',searchoptions:{sopt:['cn']}},
            {name:'PIC', index:'PIC', width:180, editable:true, search:true, stype:'text',searchoption:{sopt:['cn']}}
            ],
//      pager: jQuery('#pager'),
    gridview:true,
    pager: '#pager',
    width: '100%',
    height: '100%',
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'Date',
    sortorder: "desc",
    viewrecords: true,
    loadonce: true,
//      imgpath: 'themes/basic/images',
    caption: 'DAILY CHECK QTY',
    editurl:'process3.php',
    prmNames:{oper:'action',editoper:'editbaldefect',id:'def_id'}
});
Run Code Online (Sandbox Code Playgroud)

案例如:

loadonce: true result View 1 - 10 of 10 --> column filter can work.
loadonce: false result View 1 - 10 of 3500 --> column filter not working.
Run Code Online (Sandbox Code Playgroud)

为什么??


在开发者工具显示:

{"page":1,"total":33223,"records":"332222","rows":[]}
Run Code Online (Sandbox Code Playgroud)

但在php页面出现: 在此输入图像描述


UPDATE

我的jqgrid使用datetype : json也需要loadonce : true.我已经试过这样:

  1. 更改loadonce:false - >结果显示所有记录但不能使用工具栏过滤器
  2. 更改loadonce:true - >结果只显示10条记录,但工具栏过滤器可以工作
  3. loadonce:true,rowNum:50 - >数据只显示50(下一个按钮禁用)
  4. 在phpmyadmin检查查询 - >结果所有数据都可以显示(查询OK)
  5. 使用另一个表(OK) - >结果仍然不起作用
  6. 使用另一个页面然后附加jqgrid - >仍然无法正常工作

为什么jqgrid只检索10条记录但是这个表实际上有100.000条记录?为什么只是这个表而另一个表可以工作.

Ole*_*leg 5

jqGrid最初设计为能够使用基于服务器的数据填充网格.该选项loadonce: true稍后介绍.因此,如果您不使用loadonce(或者如果您使用loadonce: false),则服务器负责对数据进行分页,排序和过滤.每次如果用户单击列标题以按列对数据进行排序,或者如果用户填写搜索工具栏,则将发送对服务器的新请求.如果用户更改每页的行数(在寻呼机中选择其他值为10),则还将发送对服务器的新请求.选项page,rows,sidx,sord,_search和一般filters.将发送到服务器的参数的默认名称可以通过jqGrid prmNames选项进行检验(请参阅文件).

我个人总是使用stringResult: true选项filterToolbar.filters案例中参数的格式与高级搜索的格式相同(请参阅此处).

如果您使用,loadonce: true那么jqGrid只从服务器获取一次数据.因此服务器应该独立于jqGrid 的参数返回响应中的所有数据rows.服务器应该只对数据进行正确排序.性能page,total以及records来自服务器的响应会被忽略.将根据来自的数据重新计算相应的值rows.

如果使用,loadonce: true则在第一次加载数据后将jqGrid更改datatype"local".因此,所有后来对数据进行排序,分页和过滤的请求都将在本地实现,而无需向服务器发出任何其他请求.

因此,如果您使用loadonce: true并且服务器返回10行数据,那么jqGrid显示,"View 1 - 10 of 10"因为它在服务器响应中只找到10行.