tags:

views:

8274

answers:

2

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} );

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?

Any direction would be much appreciated!!!

+8  A: 

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] + '<br/>';
          }
         }
         var new_id = "1";
         return [success,message,new_id];
        }
Dan
+2  A: 
dwright