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
Example how to use addJSONData
19/03/2009
12:45
Avatar
anthonyb
Member
Members
Forum Posts: 3
Member Since:
19/03/2009
sp_UserOfflineSmall Offline

I can't get addJSONData to work. I'm doing something very simple which should work in theory. What's wrong with this piece of code?

 <table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>

$("#list")[0].addJSONData(JSON.parse("{total: 1, page: 1, records: 1, rows : [ {id: '1', cell:['1', '2007-10-01', 'test', 'note', 'new', '200.00', '10.00', '210.00']} ] }"));

Thanks,

Anthony

21/03/2009
11:36
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Do not use JSON.parse - just send the string

Regards

Tony

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.

23/03/2009
06:58
Avatar
anthonyb
Member
Members
Forum Posts: 3
Member Since:
19/03/2009
sp_UserOfflineSmall Offline

Hi Tony. Thanks for your reply but it doesn't seem to work. It's a very simple example. Have you tried it on your own machine? If so, could you post the exact code you're using? I'm using the lastest version of jqGrid.

24/03/2009
02:23
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Look at the examples - If I look right now you should do:

eval and not parse - i.e

$(”#list”)[0].addJSONData(eval("("+mystring+")"));

Regards

Tony

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.

24/03/2009
12:42
Avatar
anthonyb
Member
Members
Forum Posts: 3
Member Since:
19/03/2009
sp_UserOfflineSmall Offline

I've looked at the examples. It's still does not work. What I don't undestand is that yesterday you said:"Do not use JSON.parse - just send the string". Now you say "use eval and not parse". So, shall I just send the string or shall I use eval?

Have you actually tried the example on your machine? If so, can you post the working code?

Thanks.

26/03/2009
03:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Anthony,

Sorry, but some time I do not have access to jqGrid code in order to answer exactly. Thanks for this - I will remember - when I'm not sure I will not answer.

Look at New in version 3.3 -> Data type as function

Here we have:

..jqGrid({

...

datatype : function (pdata) {

$.ajax({

url:'server.php?q=2',

data:pdata,

dataType:"json",

complete: function(jsondata,stat)

{ if(stat=="success") {

var thegrid = jQuery("#listdt")[0];

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

}

}

});

},

...

});

Does this help?

Best Regards

Tony

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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