jqGrid - Default Add/Edit buttons - Processing Server Response

前端 未结 3 1726
孤街浪徒
孤街浪徒 2020-12-16 15:15

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 s

3条回答
  •  一整个雨季
    2020-12-16 15:49

    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

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

    --Dan

    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] + '
    '; } } var new_id = "1"; return [success,message,new_id]; }

提交回复
热议问题