Forum

May 22nd, 2014
A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

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

Topic RSS
.trigger('reloadGrid') not work.
17/10/2012
12:40
Bulgarin
Member
Forum Posts: 3
Member Since:
10/10/2012
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
justinkneff
Member
Forum Posts: 7
Member Since:
15/10/2012
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
OlegK
Germany
Member
Forum Posts: 1216
Member Since:
10/08/2009
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
dubeyniraj2010@gmail.com
New Member
Forum Posts: 1
Member Since:
15/11/2012
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
destells
New Member
Forum Posts: 2
Member Since:
14/11/2012
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: 215

Currently Online: hindos
101 Guest(s)

Currently Browsing this Page:
5 Guest(s)

Top Posters:

OlegK: 1216

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11232

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10434

Posts: 30838

Newest Members: siddharth.rc, hamerp, hindos, favipa, Overflow, Underflow

Moderators: tony (7569), Rumen[Trirand] (81)

Administrators: admin (61)

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information