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
jsonreader dot notation
04/01/2010
14:23
Avatar
xworker
Member
Members
Forum Posts: 9
Member Since:
28/12/2009
sp_UserOfflineSmall Offline

Hi

I'm trying to use the dot notation in my json reader to access data.

This json looks like this:

{"totalpages":"1", "currpage":"1","totalrecords":"1", "match":{"mid":"0","t1":{"xxx":"0","yyy":"1","p":[{"a":"1"},{"b":"2"},{"c":"3"}]},"t2":{"aaa":"1","bbb":"2",p":[{"a":"4"},{"b":"5"},{"c":"6"}]}}}

The jsonreader tries to acces the "p" list with this:

 jsonReader : {
                    root:"t1.p",
                    page: "currpage",
                    total: "totalpages",
                    records: "totalrecords",
                    repeatitems: false,
                    id: "0"
                },

But I get parser error. Is it possible to use the dot notation like that?

Thanks

x

05/01/2010
09:43
Avatar
xworker
Member
Members
Forum Posts: 9
Member Since:
28/12/2009
sp_UserOfflineSmall Offline

noone has any insights on this?

/x

06/01/2010
09:44
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This will not work.

In root element you can not set a dot notations - i.e root:"t1.p" will not work

Try to set the root to "match" item  and then in colModel set for the field the dot notation.

Example

colModel : [

....

{name:"some"... jsonmap: "t1.xxx"...}

...

]

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.

11/01/2010
20:51
Avatar
ajax head
Guest
Guests

I tried something similar, it didn't work.

The root is not "match" because match is nested, and the grid never sees the actual node it needs to recurse over, because it's nested. The grid just comes up blank. If I unnest/flatten the row data to a top level tree member, grid works great.

So I don't think this solution works, seems to me this should be a feature of the grid, to see inner data  nodes in JSON data.

Has anyone here actually tried this to see what happens?

Is there any other discussion of this subject I might have missed?

If I was going to write a solution, how best to go about it?

thx!

11/01/2010
21:27
Avatar
ajax head
Guest
Guests

I'm incorrect, the example above might work, but my data is a little different, as below.

because "cart" iis the main datanode (but is not an array), I set root to cart, but json map does not see the "contents" node below it:

{
"cart":
      {
      "nextId":null,
      "viewName":null,

     "contents":
     [
      {"id":"209660059","type":"food","quantity":"3"},
      {"id":"209661059","..

COLUMN MODEL:

    colModel:[
     {name:'contents.id',index:'contents.id',jsonmap: 'contents.id'},

     {name:'contents.type',index:'contents.type',jsonmap:'contents.type'},

     {name:'contents.quantity',index:'contents.quantity',jsonmap:'contents.quantity'}

    ]

 jsonReader : {
  root: "portfolio",
  repeatitems: false,
 ...
    },

I've tried several variations of this, none seem to work for me, does this look like it should work?

Grid comes up empty with no issues in the FBug console.

11/01/2010
21:53
Avatar
ajax head
Guest
Guests

Sorry,

I know how to set the jsonReader correctly but did not do so in my simplified example for forum use:

 jsonReader : {
  root: “cart”,
  repeatitems: false,
 …
    },

still doesn't work, I assume because "cart" is not an array that can be recursed through; looks like nested json arrays are hidden

from the grid entirely unless there is some way to map to them but I can't find anything that works for out-of-the-box config....

still I thought maybe it would see first row, but nothing.

If I need to write custom code, would appreciate some guidance as to how that might best work..

get and process JSON first, prune, submit to grid as object? hum...

13/01/2010
18:33
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Could you please send me the grid configuration and json response.

Thanks

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:
54 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