Earlz
Earlz

Reputation: 63905

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?

Upvotes: 44

Views: 115285

Answers (4)

var newdata= //You call Ajax peticion//

$("#idGrid").clearGridData();

$("#idGrid").jqGrid('setGridParam', {data:newdata)});
$("#idGrid").trigger("reloadGrid");

in event update data table

Upvotes: 0

Iniamudhan
Iniamudhan

Reputation: 518

Try this to reload jqGrid with new data

jQuery("#grid").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

Upvotes: 2

vdkotian
vdkotian

Reputation: 559

This worked for me.

jQuery('#grid').jqGrid('clearGridData');
jQuery('#grid').jqGrid('setGridParam', {data: dataToLoad});
jQuery('#grid').trigger('reloadGrid');

Upvotes: 23

Peter Bailey
Peter Bailey

Reputation: 105914

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

Upvotes: 85

Related Questions