gpt4 book ai didi

jquery - 为什么 editurl : 'clientData' when deleting a second row from jqGrid? 出现 404 错误

转载 作者:行者123 更新时间:2023-12-01 04:25:14 25 4
gpt4 key购买 nike

引用用户 @Oleg 的 jqGrid 本地编辑演示的稍微修改版本,位于此处:http://www.dataactive.net/local_editing.htm...使用下部工具栏中的垃圾箱图标或顶部工具栏上的删除按钮删除一行后,Firebug 中出现以下错误:“网络错误:404 未找到 - http://www.dataactive.net/clientArray

@Oleg 你能确定为什么会发生这种情况吗?

既然这个问题已经通过行删除解决了,我观察到的其他事情(记住这是编辑“本地数据”),当新添加的行被删除时,它们似乎并没有消失。考虑演示中的 myDelOptions 代码 (@Oleg),我正尝试在另一个脚本中使用它来实现生产目的:

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] 没有效果。任何人都可以解决这个问题吗?需要额外的代码吗?

最佳答案

你是对的。谢谢你!该示例的技巧是将 processing: true 设置为 myDelOptions 的一部分。第一次删除操作一切正常,但在第二次调用时,delGridRow 方法的另一部分将将该值重置为 processing: false

问题的解决非常简单:只需添加额外的行

options.processing = true;

myDelOptionsonclickSubmit 内部。查看修改后的演示here .

关于jquery - 为什么 editurl : 'clientData' when deleting a second row from jqGrid? 出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6899045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com