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
JSON -custom datatype function - addJSONdata
11/04/2009
20:11
Avatar
stefan-t
New Member
Members
Forum Posts: 2
Member Since:
12/04/2009
sp_UserOfflineSmall Offline

 thegrid.addJSONData(eval("(" + jsondata.responseText + ")").d);Hi,

Thanks for your excellent work .

I tried one full  workday  to solve the follow problem without success.

(jqGrid 3.5a alpha 2 -   asp.net C# 2008 - JSON.Net object serializer).

I  do a ajax call to asp.net page method

and  return the jsondata  ( formatted through JSON.Net).

Then I call

thegrid.addJSONData( eval("(" + jsondata.responseText + ")")); 

but  your function inside can't understand the data[].

if I  construct the object in javascript  then  it works.

example:

 var myJSONObject2 = { "d": { "page": "2", "totals": "15", "records": "150", "rows": [
    { "cell": ["ircEvent", "PRIVMSG", "method", "newURI", "regex"], "id": "1" },
    { "cell": ["ircEvent", "PRIVMSG", "method", "newURI", "regex"], "id": "2" },

   { "cell": ["ircEvent", "PRIVMSG", "method", "newURI", "regex"], "id": "3" },

   { "cell": ["ircEvent", "PRIVMSG", "method", "newURI", "regex"], "id": "4" },

    { "cell": ["ircEvent", "PRIVMSG", "method", "newURI", "regex"], "id": "5"}

]  } };

 thegrid.addJSONData(myJSONObject.d);    /*  O.K  !!! */

-------------------------------------------------------------------------------------

Now  the  jsondata.responseText  is formatted  like this:

{"total":"15","page":"1","records":"150","rows":[

{"id":"1","cell":["1","image","Chief Scout","Highest Award test","0"]},{"id":"2","cell":["2","image","Chief Scout","Highest Award test","0"]},{"id":"3","cell":["3","image","Chief Scout","Highest Award test","0"]},{"id":"4","cell":["4","image","Chief Scout","Highest Award test","0"]},{"id":"5","cell":["5","image","Chief Scout","Highest Award test","0"]},{"id":"6","cell":["6","image","Chief Scout","Highest Award test","0"]},{"id":"7","cell":["7","image","Chief Scout","Highest Award test","0"]},{"id":"8","cell":["8","image","Chief Scout","Highest Award test","0"]},{"id":"9","cell":["9","image","Chief Scout","Highest Award test","0"]},{"id":"10","cell":["10","image","Chief Scout","Highest Award test","0"]}

]}

thegrid.addJSONData(eval("(" + jsondata.responseText + ")"));  

/*  Failed  */

I can't see  any difference in the format  of the first JSON object.

except that the .net debugger shows the first object as structured JsonObject.

The jsondata.responseText is  string.

I tried also

  var s = eval("(" + jsondata.responseText + ")");

   var  s1 = { 'd': s };

   thegrid.addJSONData(s1.d);

without success.

Can you help me ?

Regards.

Stefan

12/04/2009
22:32
Avatar
stefan-t
New Member
Members
Forum Posts: 2
Member Since:
12/04/2009
sp_UserOfflineSmall Offline

I found a workaround to my problem :

I downloaded a javascript function equivalent to php

json_encode    from this site

http://www.bloggapedia.com/blo.....ode-818598

Then   with  jsondata.responseText

1.   var tmp = eval('(' + jsondata.responseText + ')');

2.    var myObject = json_decode(tmp.d);

3.     thegrid.addJSONData(myObject);     // Works O.K

It is a workaround.

What other can I do ?

Regards

Stefan

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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