保存行而不是恢复数据

发布于 2024-11-29 17:12:11 字数 1027 浏览 0 评论 0原文

当我选择另一行时,我想保存数据而不是恢复数据。我怎样才能做到这一点?

我一直在使用此代码进行测试,但没有任何结果:

    onSelectRow: function(row_id) { 
        if(row_id && row_id !== last_selected) {
            /*
             * Save row.
             */
            $('#grid').jqGrid('saveRow', ((last_selected !== undefined)?last_selected:row_id) , true, function() {/* OnEditFunction */}, function(response) {
                /* SuccessFunction */
                var row_to_save = ((last_selected !== undefined)?last_selected:row_id);

                success_function(row_to_save, response);

                }, 'http://some_url.com');

            last_selected = row_id;
        }   

        /*
         * Edit row.
         */
        $('grid').jqGrid('editRow', row_id, true, function() {/* OnEditFunction */}, function(response) {
            /* SuccessFunction */
            success_function(row_id, response);

            }, 'http://some_url.com'); 
    },

如果我能够在成功保存行之前触发成功函数,那就太好了,这样我就可以显示通知消息。

提前致谢。

I want to save the data instead of restore it when I select another row. How I can accomplish that?

I've been testing with this code without any results:

    onSelectRow: function(row_id) { 
        if(row_id && row_id !== last_selected) {
            /*
             * Save row.
             */
            $('#grid').jqGrid('saveRow', ((last_selected !== undefined)?last_selected:row_id) , true, function() {/* OnEditFunction */}, function(response) {
                /* SuccessFunction */
                var row_to_save = ((last_selected !== undefined)?last_selected:row_id);

                success_function(row_to_save, response);

                }, 'http://some_url.com');

            last_selected = row_id;
        }   

        /*
         * Edit row.
         */
        $('grid').jqGrid('editRow', row_id, true, function() {/* OnEditFunction */}, function(response) {
            /* SuccessFunction */
            success_function(row_id, response);

            }, 'http://some_url.com'); 
    },

It could be great if I could be able to fire a success function before the row is saved successfully, so I can show a notification message.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2024-12-06 17:12:11

我想您遇到这个问题是因为您在 saveRoweditRow。方法 editRow 只是转发 succesfunc< /code> 参数 saveRow,因此您可以在 saveRow。您可以阅读以下内容:

succesfunc:如果定义,该函数将在
请求成功。该函数传递从返回的数据
服务器。取决于服务器的数据;这个功能应该
返回 true 或 false。

因此,您至少应该包含 return true; 作为 succesfunc 实现的最后一个语句。

I suppose that you have the problem because one small error in your current implementation of the succesfunc which you use in saveRow or editRow. The method editRow just forward the succesfunc parameter to saveRow, so you will find the detailed description of the succesfunc parameter in the documentation of the saveRow. You can read the following:

succesfunc: if defined, this function is called immediately after the
request is successful. This function is passed the data returned from
the server. Depending on the data from server; this function should
return true or false.

So you should at least include return true; as the last statement of your implementation of the succesfunc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文