运行 addRowData 时 jqGrid 分组功能消失
jqGrid 的网站有以下关于如何使用分组功能的代码示例,它效果很好。
$(document).ready(function(){ var mydata = [ {id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} , {id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"}, .... ]; $("#list48").jqGrid({ data: mydata, datatype: "local", height: 'auto', rowNum: 30, rowList: [10,20,30], colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"}, {name:'name',index:'name', width:100, editable:true}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true}, {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, {name:'note',index:'note', width:150, sortable:false} ], pager: "#plist48", viewrecords: true, sortname: 'name', grouping:true, groupingView : { groupField : ['name'], groupDataSorted:false, groupColumnShow:[true] }, caption: "Grouping Array Data" });
但是如果我删除:
data: mydata,
并使用 addRowData 组成网格:
$('#list48').addRowData("id", mydata);
分组消失了,有人遇到类似的问题吗?你能帮忙吗?
谢谢!
The jqGrid's website has following code example about how to use grouping feature, it works very well.
$(document).ready(function(){ var mydata = [ {id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} , {id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"}, .... ]; $("#list48").jqGrid({ data: mydata, datatype: "local", height: 'auto', rowNum: 30, rowList: [10,20,30], colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"}, {name:'name',index:'name', width:100, editable:true}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true}, {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, {name:'note',index:'note', width:150, sortable:false} ], pager: "#plist48", viewrecords: true, sortname: 'name', grouping:true, groupingView : { groupField : ['name'], groupDataSorted:false, groupColumnShow:[true] }, caption: "Grouping Array Data" });
But if I remove:
data: mydata,
And compose the grid by using addRowData:
$('#list48').addRowData("id", mydata);
The grouping disappeared, anybody experience similar issue ? Could you please help?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在 addRowData 之后调用 sortGrid。这对我有用。 sortGrid 的语法位于 http://www.trirand.com/jqgridwiki/ doku.php?id=wiki:方法
Try calling sortGrid after addRowData. That worked for me. Syntax for sortGrid is at http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods
我也有同样的问题。只需触发“reloadGrid”就为我解决了这个问题。
$('#grid').trigger('reloadGrid');
I too had the same issue. Just triggering 'reloadGrid' solved it for me.
$('#grid').trigger('reloadGrid');
在
$('#list48').addRowData("id", mydata); 上添加行后不会进行分组。
您应该使用网格中添加的新数据重新分组。将行添加到网格后尝试此操作。
Grouping is not taken after adding rows on
$('#list48').addRowData("id", mydata);
You should re-group with new data added in grid. Try this after adding rows to grid.