Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqgrid not reloading after making a ajax call using trigger('reload')

I am trying to reload the grid with new data which is just been changed , so that user can see the new data with modification .

my approach:

jQuery("#relCasePick").click( function(){

   var ids=jQuery("#list10").jqGrid('getGridParam','selarrrow');

   $.ajax({
      type: "POST",
      url: "/cpsb/unprocessedOrders.do?method=releaseToCasePick&orderNumbers="+ids,
      data: JSON.stringify(ids), 
      dataType: "json"
   });

   jQuery("#list10").setGridParam({rowNum:10,datatype:"json"}).trigger('reloadGrid');
}); 

when I am clicking this button.. I am sending the data correctly but when I am reloading its not updated with new data....I will really appreciate if someone can help ..

like image 243
paul Avatar asked Sep 20 '10 19:09

paul


1 Answers

What I see here is an Ajax call to post and another to reload the grid. The problem here is Which ajax call will finish first?. You dont know. Your best bet would be to use the success call back function in the Ajax post. This will reload the grid if and only if the post was successful.

jQuery("#relCasePick").click( function(){ 

  var ids =jQuery("#list10").jqGrid('getGridParam','selarrrow'); 

   $.ajax({ 
     type: "POST", 
     url: "/cpsb/unprocessedOrders.do?method=releaseToCasePick&orderNumbers="+ids, 
     data: JSON.stringify(ids),  
     dataType: "json",
     success: function(data) {
       jQuery("#list10").setGridParam({rowNum:10,datatype:"json" }).trigger('reloadGrid'); 
     }
  }); 
});  
like image 111
John Hartsock Avatar answered Sep 24 '22 21:09

John Hartsock