Forum


23:13

01/04/2011

Is there a way using the jsonReader or maybe with an event that a JSON object returned from an AJAX call can be translated into something the jqGrid can understand?
We have standard JSON objects gen'd from data model classes that I can return sort of like this:
{
items: [
{ fname: 'Jon', lname: 'Doe', homeAddress: { address1: '123 Main St.', city: 'Sometown', ... }, status: { id: 1, description: 'active' } },
{ fname: 'Jane', lname: 'Doe', homeAddress: { address1: '123 Main St.', city: 'Sometown', ... }, status: { id: 1, description: 'active' } },
...
]
}
Which is totally non-conformant... is there a way/place I can inject a function in JS to convert it? I tried modifying the "success" function of the xhr via the loadBeforeSend(xhr) event, but it didn't like it.
I'm using 3.8.2 for now, btw.
23:39

01/04/2011

I actually found a solution for this - adding ajaxGridOptions to my grid config options and using the dataFilter:
the "convert" function takes whatever I received from the AJAX call and converts it to the jqGrid standard with rows / cell / etc. The interesting thing is that regardless of setting the datatype to JSON it seems to always pass in and want returned a string value. So I have to parse the JSON string, convert to a new object, then stringify the converted object before returning it.
Most Users Ever Online: 715
Currently Online:
48 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66