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
jqgrid json help (jsonreader configuration problem)
29/06/2010
02:09
Avatar
mikeerickson
Huntington Beach, CA
Member
Members
Forum Posts: 34
Member Since:
29/06/2010
sp_UserOfflineSmall Offline

I need help displaying seemingly simple JSON table. This displays grid and shows “Loading” but never shows data. i have looked all over for examples but am not able to get it work :(  I know I need to create a jsonReader property, but I cant seem to figure it out based on my data (see link below)

JSON Source: http://www.asgsoft.com/states.json

Code:

$(“#statesGrid”).jqGrid({
url:’states.json’,
datatype: “json”,
colNames:["name", "abbreviation","capital","most-populous-city","square-miles","time-zone-1","time-zone-2","dat"],
colModel:[
{name:'name',index:'name', width:75},
{name:'abbreviation',index:'abbreviation', width:90},
{name:'capital',index:'capital', width:100},
{name:'most popular city',index:'most-populous-city', width:80, align:"right"},
{name:'square miles',index:'square-miles', width:80, align:"right"},
{name:'time zone 1',index:'time-zone-1', width:80,align:"right"},
{name:'time zone 2',index:'time-zone-2', width:150, sortable:false},
{name:'dat',index:'dat',width:200}
],
rowNum:10,
rowList:[10,20,30],
pager: ‘#pager’,
sortname: ‘name’,
viewrecords: true,
sortorder: “desc”,
caption:”States”
});

mse

01/07/2010
12:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Mike,

Instead that I point you to the right direction, it seems that you do not have read the docs to the end.

You should read the other chapter from the docs - JSON dot notation.

http://www.trirand.com/jqgridw.....t_notation

So in order to work this yo should first configurire the jsonReader

jsonReader : {

root : "states.state",

repeatitems: false

}

and then in your colModel to you the property jsonmap. I will do for the first field, you will finish the other.

colModel:[
{name:'name',index:'name', width:75, jsonmap:"@attributes.name"}

...

// do it for others

},

]

Hope 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.

01/07/2010
18:55
Avatar
mikeerickson
Huntington Beach, CA
Member
Members
Forum Posts: 34
Member Since:
29/06/2010
sp_UserOfflineSmall Offline

Tony,

Well, it seems I have a better understanding now of how it should be configured and how to use the dot notation, but alas I am still not any further visa vis display of data.   Here is my jqgrid call, can you see anything here that is wrong?

$("#statesGrid").jqGrid({

url:'states.json',

datatype: "json",

colNames: ["name","abbreviation","capital","most-populous-city","square-miles","time-zone-1","time-zone-2","dst"],

colModel: [

{name:"name",index:"name",jsonmap:"@attributes.name"},

{name:"abbreviation",index:"abbreviation",jsonmap:"@attributes.abbreviation"},

{name:"capital",index:"capital",jsonmap:"@attributes.capital"},

{name:"most popular city",index:"most-populous-city",jsonmap:"@attributes.most-populous-city"},

{name:"square miles",index:"square-miles",jsonmap:"@attributes.square-miles"},

{name:"time zone 1",index:"time-zone-1",jsonmap:"@attributes.time-zone-1"},

{name:"time zone 2",index:"time-zone-2",jsonmap:"@attributes.time-zone-2"},

{name:"dst",index:"dst",jsonmap:"@attributes.dst"}

],

rowNum:10,

rowList:[10,20,30],

pager: '#pager',

sortname: 'name',

viewrecords: true,

sortorder: "desc",

caption:"States",

jsonReader: {

root: "states.state",

repeatitems: false

},

});


mse

08/07/2010
20:10
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Just tested your configuration with the data provided from the link.

It works perfectly except that:

1. You have errror into the code:

...jqGrid({
..
jsonReader: {
root: "states.state",
repeatitems: false
}, <==========Error
});

2. You should provide a info for the page, but instead it work without this setting.
If you need online example with your settings I'm ready to prepare for you.

Kind 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.

08/07/2010
20:30
Avatar
mikeerickson
Huntington Beach, CA
Member
Members
Forum Posts: 34
Member Since:
29/06/2010
sp_UserOfflineSmall Offline

tony said:

Hello,

Just tested your configuration with the data provided from the link.

It works perfectly except that:

1. You have errror into the code:

...jqGrid({
..
jsonReader: {
root: "states.state",
repeatitems: false
}, <==========Error
});

2. You should provide a info for the page, but instead it work without this setting.
If you need online example with your settings I'm ready to prepare for you.

Kind Regards
Tony


Thanks for the reply, but I still dont have it working.   I have made the adjustment you have defined above, still nothing.  I have even simplified the JSON source to be more "standard" and edited my javascript file and still doesnt work.  I can send you both my source file and the modified .json file if you would like? 

mse

08/07/2010
20:42
Avatar
mikeerickson
Huntington Beach, CA
Member
Members
Forum Posts: 34
Member Since:
29/06/2010
sp_UserOfflineSmall Offline

tony said:

Hello,

Just tested your configuration with the data provided from the link.

It works perfectly except that:

1. You have errror into the code:

...jqGrid({
..
jsonReader: {
root: "states.state",
repeatitems: false
}, <==========Error
});

2. You should provide a info for the page, but instead it work without this setting.
If you need online example with your settings I'm ready to prepare for you.

Kind Regards
Tony


Tony

One more thing, I always seem to get the same error in Firebug no matter what I do (this is in http://localhost:8888/jqGridPH.....rid.min.js)

a.rows is undefined

mse

08/07/2010
22:27
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

The question is – which version of jqGrid is used?

How look your head section where the jqgrid files are loaded?

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.

08/07/2010
22:43
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Here is your config with the response:

http://trirand.com/blog/jqgrid.....demo3.html

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.

08/07/2010
22:54
Avatar
mikeerickson
Huntington Beach, CA
Member
Members
Forum Posts: 34
Member Since:
29/06/2010
sp_UserOfflineSmall Offline

tony said:

Hello,

Here is your config with the response:

http://trirand.com/blog/jqgrid.....demo3.html

Regards

Tony


Well, after all this, I found the problem.   In my page, my list object was defined as:

<div id="statesGrid"></div>

changed to

<table id="statesGrid"></table>

And guess what, it worked!  

What does it take to get the column sorting work?

mse

06/07/2011
02:59
Avatar
amarjeet27
New Member
Members
Forum Posts: 1
Member Since:
06/07/2011
sp_UserOfflineSmall Offline

I am also unable to get column sorting to work. Any suggestions?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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