jqGrid-默认的“添加/编辑"按钮-处理服务器响应 [英] jqGrid - Default Add/Edit buttons - Processing Server Response

查看:67
本文介绍了jqGrid-默认的“添加/编辑"按钮-处理服务器响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做 jqGrid 的第一个实现.我正在使用navGrid中显示的标准添加/编辑按钮,但是在单击编辑/添加表单中的提交"时,无法确定如何处理服务器响应.

I am working on my first implementation of a jqGrid. I am using the standard add/edit buttons that appear in the navGrid but am having problems identifying how process the server response when I click Submit in the edit/add forms.

.navGrid("#product-codes-footer",{edit:true,add:true,del:false},
{afterShowForm:afterShowEdit}, {afterShowForm:afterShowAdd} );

是否存在与此相关的标准回调或事件参数?有没有办法定义saveRow的调用方式,还是可以实现的默认成功/错误回调方法?

Is there a standard callback or event parameter I am missing somewhere regarding this? Is there a way to define how saveRow is called or is there a default success/error callback method I can implement?

任何方向将不胜感激!

推荐答案

似乎有一些事件参数我无法完全读取并理解...

There appears to be a couple event parameters that I failed to completely read and comprehend...

API-> http://www.trirand. com/jqgridwiki/doku.php?id = wiki:form_editing#editgridrow

使用afterSubmit和afterComplete的事件参数可以让我处理服务器响应并更新表单.

using the event parameters for afterSubmit and afterComplete allow me to process the server response and update the form.

-丹

编辑 这是所用代码的示例...

EDIT Here is an example of the code used...

.navGrid(
        "#product-codes-footer",
        {edit:true,add:true,del:false}, 
        {
            afterShowForm:afterShowEdit, 
            afterSubmit:processAddEdit,
            beforeSubmit:validateData,
            closeAfterAdd: true,
            closeAfterEdit: true
        }, 
        {
            afterShowForm:afterShowAdd, 
            afterSubmit:processAddEdit,
            beforeSubmit:validateData,
            closeAfterAdd: true,
            closeAfterEdit: true
        } 
);
function afterShowEdit(formId) {

            //do stuff after the form is rendered
        }
        function afterShowAdd(formId) {

            //do stuff after the form is rendered
        }
        function processAddEdit(response, postdata) {
            var success = true;
            var message = ""
            var json = eval('(' + response.responseText + ')');
            if(json.errors) {
                success = false;
                for(i=0; i < json.errors.length; i++) {
                    message += json.errors[i] + '<br/>';
                }
            }
            var new_id = "1";
            return [success,message,new_id];
        }

这篇关于jqGrid-默认的“添加/编辑"按钮-处理服务器响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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