5

这是正常的还是我错过了什么?

如果我设置loadonce: true,我的网格只返回 5 条记录。

但是,如果我将其更改为loadonce: false,则网格将获取所有记录

我的代码如下。

$("#leave-detail-grid").jqGrid({
    url:'grid/grid_leave_detail.php',
    datatype: 'xml',
    mtype: 'GET',
    colNames:['Date','Day','Approver','Leave Type','Status','Purpose | Reason'],
    colModel :[
      {name:'start_date', index:'start_date', width:80, editable:false, align:"left", editrules:{required:true}},
      {name:'day', index:'day', width:80, editable:false, align:"left", editrules:{required:true}},
      {name:'sup', index:'sup', width:130, editable:false, align:"left", editrules:{required:true}},
      {name:'desc', index:'desc', width:130, editable:false, align:"left", editrules:{required:true}},
      {name:'status', index:'status', width:80, editable:false, align:"center", editrules:{required:true}},
      {name:'purpose', index:'purpose', width:180, editable:false, align:"left", editrules:{required:true}}    
    ],
    height: 'auto',
    pager: '#leave-detail-pager',
    pgbuttons: true,
    pginput: 'Yes',
    pgtext: 'Yes',
    rowNum:5,
    rowList:[20,40,100,200,400],
    sortname: 'start_date',
    sortorder: 'asc',
    loadonce: true, // to enable sorting on client side
    viewrecords: true,
    gridview: true,
    caption: 'Search Purpose'
});
$("#leave-detail-grid").jqGrid('navGrid',"#leave-detail-pager",
      {edit:false,add:false,del:false,search:true},
      {zIndex:5234},{zIndex:5234},{zIndex:5234},{zIndex:5234}
);
4

4 回答 4

3

谢谢乔纳森。我怎么会错过那个演示:)

我添加 colModelrowTotal: 2000,值 -1 不起作用,这将显示 2000 recs

然后将以下内容添加到我的服务器代码中

$totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false;
if($totalrows) {
$limit = $totalrows;
}

为了加载所有记录,我们需要调整服务器代码以覆盖 rowTotal 参数。

$result = mysql_query("SELECT COUNT(*) AS count FROM leaveform WHERE emp_id='$emp_id'   AND company_id='$company_id'"); 
$row = mysql_fetch_array($result,MYSQL_ASSOC); 
$count = $row['count']; 
$totalrows =  $count;
$limit = $totalrows;
于 2012-01-29T02:30:52.310 回答
1

rowNum:5,意味着网格将只使用 5 行。

loadonce: true意味着它只会加载一次。它还禁用寻呼机。

基于此配置,该网格将仅使用 5 行,并且由于它不再从服务器加载,因此将始终是相同的 5。

这里是 Wiki 的链接,其中包含最新的选项文档:http ://www.trirand.com/jqgridwiki/doku.php?id=wiki:options

于 2012-01-28T15:39:34.263 回答
1

如果使用loadonce: true服务器应该返回所有行。数据应该按照sortnamesortorder参数进行排序,这些参数将作为sidx和发送到服务器sord

将显示返回数据的第一页。您仍然可以使用数据的本地分页、排序和过滤(搜索)。

定义sorttype参数以允许对数据进行正确的本地排序可能很重要。

如果您仍然有问题,您应该将您的问题附加到服务器的 XML 响应中。因此,您问题的其他读者将能够重现该问题。

最后一点:您对 jqGrid的pginput, 和options 使用了非常奇怪的值。pgtext您最好保留文档中描述的选项类型。

于 2012-01-28T21:09:44.917 回答
0

{ rowNum: 0 } 设置无限制行...

于 2013-01-30T11:58:30.320 回答