Forum


02:09

29/06/2010

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
12:30

Moderators
30/10/2007

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.
18:55

29/06/2010

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
20:10

Moderators
30/10/2007

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.
20:30

29/06/2010

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
20:42

29/06/2010

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)
mse
22:27

Moderators
30/10/2007

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.
22:43

Moderators
30/10/2007

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

29/06/2010

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
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66