Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
.trigger('reloadGrid') not work.
17/10/2012
12:40
Avatar
Bulgarin
Member
Members
Forum Posts: 3
Member Since:
10/10/2012
sp_UserOfflineSmall Offline

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!

18/10/2012
15:42
Avatar
justinkneff
Member
Members
Forum Posts: 7
Member Since:
15/10/2012
sp_UserOfflineSmall Offline

Try adding the following parameters to foce the data type too:

 $('#myJqGrid').setGridParam({ page: 1, datatype: "json" }).trigger('reloadGrid');
18/10/2012
19:30
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I suppose that the problem exist because old data values will be not removed by

jQuery("#myJqGrid").jqGrid('setGridParam', { data: data });

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:

var referenceToInternalData = jQuery("#myJqGrid").jqGrid("getGridParam", "data");
referenceToInternalData = data;

or just

jQuery("#myJqGrid")[0].p.data = data;

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

jQuery.extend(true, this.p, {data: data});

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

15/11/2012
10:56
Avatar
dubeyniraj2010@gmail.com
New Member
Members
Forum Posts: 1
Member Since:
15/11/2012
sp_UserOfflineSmall Offline

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



15/11/2012
14:45
Avatar
destells
New Member
Members
Forum Posts: 2
Member Since:
14/11/2012
sp_UserOfflineSmall Offline

Hello.

I had the same problem and I solved it as follow:

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

Best regards.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
44 Guest(s)

Currently Browsing this Page:
1 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information