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
toJSON conflict with toJson in inline editing save event
21/11/2012
20:53
Avatar
zkmiller
Virginia
Member
Members
Forum Posts: 6
Member Since:
19/11/2012
sp_UserOfflineSmall Offline

I am using jqGrid 4.4.1 and I recently added json2.js because I need to convert a javascript array object to a string to save on the page and then pass this value back on the next request.  However, including json2 on the page breaks inline editing for jqgrid.  When I remove the include for json2 then inline editing works as expected.

 The error that I get is that ‘Line 191 Error: Object doesn't support this property or method’ of json2.js that is caught in the save event prior to making the ajax call to the server.

My guess is that when JSON.stringify checks to see if the js object has a toJSON method it doesn't find one and calls it's own toJSON.  But since jqGrid has a toJson method it also is called - possibly before the JSON.stringify call - and causes JSON.toJSON to throw an error.

How can we fix or get arround this? This happens in IE7 or older.  I wouldn't normally worry about this but I have to handle IE7 clients with this site.

Thanks for any help with this.

22/11/2012
12:02
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I do not agree with this.

Please check your code again. Do you have a custom code when you do inline edit?

Th grid has its own toJoson methos but it is never called in inlinedit.

Moreover the method is ecloased in a class and is called this way:

xmlJsonClass.toJson(....)

The problem you may face is in parse function.

jqGrid check if the browser has a build in JSON and if not uses a eval.

Also this is possible if the flag

$.jgrid.useJSON = true;

If you maybe set this flag after loading the grid to false you maybe will not have problem in IE7.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

26/11/2012
21:48
Avatar
zkmiller
Virginia
Member
Members
Forum Posts: 6
Member Since:
19/11/2012
sp_UserOfflineSmall Offline

Tony, thanks for the suggestion. I tried it but it didn't help.  The browser (IE7) does not have a built-in toJSON, that is why I included json2.js to support the JSON.stringify function.  I need to support IE7 and IE8 with this site so I would like to find a way to make this work.

When I use the IE Developers tools in the 'Debug' mode I can step through the process of 'save-row' and the object passed to jquery to process has a Method : 'toJSON' : 'toJSON()' (in IE7 but not in IE8). Not sure what to do with that information.

Any more suggestions?

Zeke


27/11/2012
16:03
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Do not use json2 (exclude it from your include) and use  the jqGrid json functions  - they  are the same.

See jqGrid build in json functions.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

27/11/2012
17:26
Avatar
zkmiller
Virginia
Member
Members
Forum Posts: 6
Member Since:
19/11/2012
sp_UserOfflineSmall Offline

It doesn't look like the built in json functions will support converting a javascript array to a json string.  It looks like it will only convert a DOM element to json. Am I missing something?  I have included json2 because I need to stringify an array that I got using jqGrid.getRowData so I can send it to a controller action that will create an Excel spreadsheet.  If I could stringify the array in some other way I would.

Regards


27/11/2012
18:04
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

It seeems to me you do not read carfully my previous post.

You can use

xmlJsonClass.toJson( object, name, ...)

This function do what you want. There are other two default parameters (please look at this function).
The function is used in filtering (seraching) and other places if the the build in tojson is not available.

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

27/11/2012
18:46
Avatar
zkmiller
Virginia
Member
Members
Forum Posts: 6
Member Since:
19/11/2012
sp_UserOfflineSmall Offline

Tony,

Thank you for your help and especially your patience. I'm pretty new to jqGrid and it seems I am always trying to do something no one else has talked about if they have done it. Most probably I am trying to do something the hard way when it should be very simple. In any case I am trying to use your suggestion but I haven't been able to get it to work.  I am trying to get row data from a jqGrid using:

var rowdata =$(id).getRowData();

Once I have the row data in an array I need to convert to a json string so that I can post it to my controller action. How do I apply your suggestion?

Thanks again for your patience,

Zeke

27/11/2012
22:08
Avatar
zkmiller
Virginia
Member
Members
Forum Posts: 6
Member Since:
19/11/2012
sp_UserOfflineSmall Offline

I finally got it to work sort of.  Now to get PHP to do it's job with the data string.

Thanks again for all your help.

Zeke

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
58 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