0

我对这个问题很困惑,因为我是 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'}
});

像这样的情况:

loadonce: true result View 1 - 10 of 10 --> column filter can work.
loadonce: false result View 1 - 10 of 3500 --> column filter not working.

为什么??


在开发者工具展上:

{"page":1,"total":33223,"records":"332222","rows":[]}

但在php页面出现: enter image description here


更新

我的 jqgrid 使用datetype : json并且还需要loadonce : true。我已经尝试过这样的:

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

why jqgrid just retrieve 10 records only however this table actually have 100.000 records? and why just this table whereas another table can work.

4

1 回答 1

5

jqGrid was designed originally to be able to fill grid with server based data. The option loadonce: true was introduced later. So if you don't use loadonce (or if you use loadonce: false) the server is responsible for paging, sorting and filtering of the data. Every time if the user click on the column header to sort the data by the column or if the user fill searching toolbar the new request to the server will be sent. If the user change the number of rows per page (choose other value as 10 in the pager) the new request to the server will be also send. The options page, rows, sidx, sord, _search and typically filters. Default names of parameters which will be sent to the server can be chaneged by prmNames option of jqGrid (see the documentation).

I personally use always stringResult: true option of filterToolbar. The format of filters parameter in the case is the same as for Advanced Searching (see here).

If you use loadonce: true then jqGrid get the data from the server only once. So the server should return all data in the response independent on the rows parameter of jqGrid. The server should only sort the data correctly. The properties page, total and records from the server response will be ignored. The corresponding values will be recalculated based on the data from rows.

If you use loadonce: true then jqGrid change datatype to "local" after the first loading of data. So all later requests for sorting, paging and filtering of data will be implemented locally without any additional request to the server.

So if you use loadonce: true and the server return 10 rows of data then jqGrid display "View 1 - 10 of 10" because it found only 10 rows in the server response.

于 2012-11-02T10:26:48.793 回答