jqgrid:动态添加记录后排序不起作用
jqgrid: Sorting not working after dynamically adding records
我有一个jqgrid,它最初填充了一些记录。用户可以选择向网格中添加更多行。但是,在添加新行之后,如果用户试图对记录进行排序,结果会不一致,并且一些记录会在网格中丢失。
小提琴手:https://jsfiddle.net/99x50s2s/68/
HTML:
<table id="sg1"></table>
<div id="psg1"></div>
</br>
<button id="new" type="button">Add New</button>
代码:
jQuery("#sg1").jqGrid({
datatype: "local",
gridview: true,
loadonce: true,
shrinkToFit: false,
autoencode: true,
height: 'auto',
viewrecords: true,
sortorder: "desc",
scrollrows: true,
loadui: 'disable',
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"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
caption: "Test Grid"
});
var initialData = [
{Id:"1",invdate:"2007-10-01",name:"test 12349",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{Id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}
];
var subData = [
{Id:"3",invdate:"2007-10-01",name:"test 12349",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{Id:"4",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}
];
jQuery("#sg1")[0].addJSONData(initialData);
var i=2;
$('#new').on('click', function(){
i = i+i;
jQuery("#sg1").jqGrid(
'addRowData',
$.jgrid.randId(),
{Id:i,invdate:"2007-10-02",name:"test"+i,note:"note" + i,amount:"300.00",tax:"20.00",total:"320.00"});
});
复制步骤:
a。启动fiddler(你会看到一个有2条记录的测试网格)b.现在,单击"添加新"按钮,然后尝试通过单击任何列标题进行排序。
问题:
代码有什么问题吗?为什么有些记录正在消失?
环境:jqgrid 4.6.0、jquery 1.11.1和IE 9
必须使用addRow
方法来追加数据。这是一把更新的小提琴https://jsfiddle.net/99x50s2s/69/
$('#new').on('click', function(){
i = i+i;
var parameters =
{
initdata : {Id:i,invdate:"2007-10-02",name:"test"+i,note:"note" + i,amount:"300.00",tax:"20.00",total:"320.00"},
position :"last"
};
jQuery("#sg1").jqGrid('addRow',parameters);
});
相关文章:
- jquery中DataTables插件中的排序不起作用
- j查询排序不起作用
- 为什么这种 jquery 驱动的表排序不起作用
- jQuery DataTables排序不起作用
- populate中的Mongoose排序不起作用
- 使用J-query数据表,美国日期格式的自定义排序不起作用
- jQuery 表排序器排序不起作用
- 从 AJAX 调用的 PHP 对数组进行排序不起作用
- Jquery UI 可排序不起作用
- 基于CSS类和文本对元素进行排序不起作用
- 使用嵌套json时,ngTable中的排序不起作用
- js文档排序不起作用
- jQueryDataTables-当日期也是一个链接时,排序不起作用
- angularJS:动态标题排序不起作用
- ng表排序不起作用
- 淘汰排序不起作用
- SlickGrid:重新排序后的排序不起作用
- 数据表排序不起作用
- 数组排序不起作用
- jqgrid:动态添加记录后排序不起作用