Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh the data in a jqGrid?

I have been trying to get a grid to be updated from the datasource when a button is pushed.

So I have in the click event something like this:

$('#grid').jqGrid('trigger','reloadGrid'); 

However this does not work and I get an error thrown for unknown method 'trigger'

I have also tried

$('#grid').jqGrid('trigger("reloadGrid")'); 

How would I execute this function?

like image 923
Earlz Avatar asked Jun 28 '10 18:06

Earlz


People also ask

How do I reset jqGrid?

jqGrid('clearGridData') . jqGrid('setGridParam', {data: data, page: 1}) . trigger('reloadGrid'); } } }); )};

How do you use jqGrid?

In this step, we are going to add jqGrid Script and CSS reference to index view. This script is added to project when we add jqGrid Grid from NuGet package. After adding Scripts and Css next we need to add table element for reserve the place where the grid should be created.

What is Loadonce in jqGrid?

If you use loadonce:true jqGrid change the datatype parameters to 'local' after the first load of data from the grid. All next grid reloading (sorting, paging, filtering) works local. If you want refresh the grid data from the server one more time you should set datatype to its original value ('json' or 'xml').


2 Answers

$('#grid').trigger( 'reloadGrid' ); 
like image 197
Peter Bailey Avatar answered Sep 17 '22 00:09

Peter Bailey


This worked for me.

jQuery('#grid').jqGrid('clearGridData'); jQuery('#grid').jqGrid('setGridParam', {data: dataToLoad}); jQuery('#grid').trigger('reloadGrid'); 
like image 21
vdkotian Avatar answered Sep 19 '22 00:09

vdkotian