【发布时间】:2011-08-01 13:25:45
【问题描述】:
参考用户@Oleg 对jqGrid 本地编辑演示的略微修改版本,位于此处:http://www.dataactive.net/local_editing.htm ...使用下方工具栏中的垃圾箱图标或顶部工具栏上的删除按钮删除一行后,Firebug 中会出现以下错误: "NetworkError: 404 Not Found - http://www.dataactive.net/clientArray"
@Oleg 你能确定为什么会发生这种情况吗?
现在通过删除行解决了这个问题,我观察到的其他事情(记住这是编辑“本地数据”),当新添加的行被删除时,它们似乎并没有消失。考虑一下我试图在另一个脚本中用于生产目的的演示 (@Oleg) 中的 myDelOptions 代码:
myDelOptions = {
// because I use "local" data I don't want to send the changes
// to the server so I use "processing:true" setting and delete
// the row manually in onclickSubmit
onclickSubmit: function (options, rowid) {
var grid_id = $.jgrid.jqID(grid[0].id),
grid_p = grid[0].p,
newPage = grid_p.page;
// reset the value of processing option to true to
// skip the ajax request to 'clientArray'.
options.processing = true;
// delete the row
grid.delRowData(rowid);
$.jgrid.hideModal("#delmod" + grid_id,
{ gb: "#gbox_" + grid_id,
jqm: options.jqModal, onClose: options.onClose
});
$("#list")[0].refreshIndex();
setTimeout(function () {
$("#list").trigger("reloadGrid", [{ current: true}]);
}, 100);
calculateTotal();
if (grid_p.lastpage > 1) {// on the multipage grid reload the grid
if (grid_p.reccount === 0 && newPage === grid_p.lastpage) {
// if after deliting there are no rows on the current page
// which is the last page of the grid
newPage--; // go to the previous page
}
// reload grid to make the row from the next page visable.
grid.trigger("reloadGrid", [{ page: newPage}]);
}
return true;
},
processing: true
};
迭代行对象的calculateTotal() 函数仅获取剩余行的列的数值并将它们重新汇总到摘要页脚行,但发生的是迭代行对象网格显示“已删除”的行仍然存在,在数组或其他东西中,因此无法计算新的总数,因为似乎没有任何变化,这些行实际上并没有被删除。我不明白在本地数据的上下文中使用“delRowData”时实际发生了什么,但它似乎只是从可视网格中“删除”该行,但它仍然是行对象的一部分。而且,更奇怪的是,如果添加了另一个新行,则“已删除”的行会重新出现,就像它们在新行之外一样。如您所见,我有refreshIndex[0] 和trigger(reload),但如果trigger("reload") 存在且refreshIndex[0] 无效,则该行不会删除。任何人都可以解决这个问题吗?需要额外的代码吗?
【问题讨论】: