为什么editurl有404错误:'clientData'从jqGrid删除第二行时? [英] Why a 404 error for editurl: 'clientData' when deleting a second row from jqGrid?

查看:63
本文介绍了为什么editurl有404错误:'clientData'从jqGrid删除第二行时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅位于此处的用户@Oleg对jqGrid本地编辑演示的略微修改版本: http:/ /www.dataactive.net/local_editing.htm
...使用下方工具栏中的垃圾箱图标或顶部工具栏上的删除按钮删除一行后,会出现以下错误在Firebug中:
NetworkError:404 Not Found - http://www.dataactive.net/clientArray

Referring to a slightly modified version of a jqGrid local editing demo by user @Oleg located here: http://www.dataactive.net/local_editing.htm ...after one row is deleted using either the rubbish bin icon in the lower toolbar or the Delete button on the top toolbar, the following error is given in Firebug: "NetworkError: 404 Not Found - http://www.dataactive.net/clientArray"

@Oleg你能确定这种情况发生的原因吗?

@Oleg are you able to ascertain why this happens?

现在这个问题已经解决了行删除,我观察到的其他东西(记住这是编辑本地数据),当新添加的行被删除时,它们似乎没有消失。考虑你的demo(@Oleg)中的myDelOptions代码,我试图在另一个脚本中用于生产目的:

Now that that problem is solved with the row deletion, something else I observe (keeping in mind this is editing "local data"), when newly added rows are deleted they don't seem to vanish. Consider the myDelOptions code from your demo (@Oleg) which I'm trying to use in another script for a production purpose:

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] 触发器(重新加载)但如果<$行,则不会删除该行c $ c>触发器(reload)在那里, refreshIndex [0] 无效。任何人都可以解决这个问题吗?需要额外的代码?

the calculateTotal() function which iterates through the row object, simply takes the numeric values of the columns of the rows that remain and re-totals them to a summary footer row but what is happening is that iterating through the row object of the grid shows the "deleted" rows are still there, in the array or something, and so a new total cannot be calculated because nothing seems to have changed, the rows are not actually deleted. I don't understand what actually happens when "delRowData" is used in context of local data but it appears to only "remove" the row from the visual grid but it is still part of the row object. And, stranger yet, if another new row is added, the "deleted" row(s) re-appear exactly as they were in addition to the new row. As you can see I have refreshIndex[0] and trigger(reload) but the row does not delete if trigger("reload") is there and refreshIndex[0] has no effect. Can anyone address any of this? Additional code required?

推荐答案

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

You are right. Thank you! The trick on the example is to set processing: true as the part of myDelOptions. At the first delete operation is everything OK, but the value will be reset to processing: false by another part of the delGridRow method at the second call of it.

问题的解决方法很简单:一个应该只添加额外的行

The fix of the problem is very easy: one should just add additional line

options.processing = true;

onclickSubmit myDelOptions 。请参阅修改后的演示此处

inside of the onclickSubmit of the myDelOptions. See the modified demo here.

这篇关于为什么editurl有404错误:'clientData'从jqGrid删除第二行时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆