Forum


12:40

10/10/2012

Hello.
I have a problem – My grid can't refresh… I add a button to delete a file from my system. In the end of 'onclick'-method for this button I have
$.ajax({
url: 'MyPage,
data: "{}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8″,
success: function(data) {
jQuery("#myJqGrid").jqGrid('setGridParam', { data: data }).trigger('reloadGrid');
}
});
And with this I get new data from codebehind method in "MyPage" (this is aspx page). 'data'-object has new values , set it to grid's data, but not refresh the grid with new values.
Can you help me?
Thanks!
19:30

10/08/2009

I suppose that the problem exist because old data values will be not removed by
The above code works good with empty data, but it could worrk wrong if another (old) data already exist. What you can do is setting the data array using getGridParam:
referenceToInternalData = data;
or just
because jQuery("#myJqGrid")[0].p represents the internal parameters of jqGrid.
The reason of the problem is that setGridParam uses jQuery.extend internally (see the source code of jqGrid). One uses
So the object {data: data} will be recursively merged with the old options of the grid (with jQuery("#myJqGrid")[0].p). You can read in the documentation of jQuery.extend:
On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
So the old data values will be merged instead of replacing by setGridParam.
Best regards
Oleg
10:56

15/11/2012

Hello,
the problem with setGridParam is that it appends parameter values and not replaces to solve this you will have to first set parameter values to null, then reset them with new values.
jq("#list").setGridParam({ postData: null });
jq('#list').setGridParam({ postData: { '_ItemNo': jq('#item').val(), '_Variant': jq('#itemVariant').val() } }).trigger('reloadGrid');
Best Regards,
Niraj
Most Users Ever Online: 715
Currently Online:
46 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66