Forum


05:27

17/02/2010

I can't get data into the grid. Here's the grid definition:
colNames:['HCS ID','HCS Name', 'City','Current Hospitals','Max Hospitals'],
colModel :[
{name:'EntityID', index:'EntityID', hidden:true, key:true},
{name:'Name', index:'Name', width:200},
{name:'CityState', index:'CityState', width:160},
{name:'HospitalCount', index:'HospitalCount', width:130, align:'center'},
{name:'MaxHospitals', index:'MaxHospitals', width:110, align:'center'} ],
caption: 'Select an HCS:',
forceFit:true,
hidegrid:false,
scroll:true,
scrollrows:true,
url:'ajax/GetHcsList.php?name=h',
datatype:'json'
});
Here's the data returned by the PHP file:
(opening brace)
total:1,
page:1,
records:23,
rows:[{EntityID:30, Name:"HCN 2/13 #1", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:37, Name:"HCN 2/13 #10", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:38, Name:"HCN 2/13 #11", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:39, Name:"HCN 2/13 #12", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:40, Name:"HCN 2/13 #13", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:31, Name:"HCN 2/13 #2", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:32, Name:"HCN 2/13 #3", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:33, Name:"HCN 2/13 #4", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:34, Name:"HCN 2/13 #6", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:35, Name:"HCN 2/13 #8", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:36, Name:"HCN 2/13 #9", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:29, Name:"HCN1", City:", ", HospitalCount:1, MaxHospitals:0},
{EntityID:245, Name:"HCS 101", City:"111, ", HospitalCount:1, MaxHospitals:0},
{EntityID:246, Name:"HCS 2", City:"2, ", HospitalCount:1, MaxHospitals:0},
{EntityID:341, Name:"HCS Sept", City:"lkjfldkjgdlkj, ", HospitalCount:2, MaxHospitals:0},
{EntityID:402, Name:"HCS0509", City:"kk, ", HospitalCount:1, MaxHospitals:1},
{EntityID:392, Name:"HCS2007", City:"ffdf, ", HospitalCount:1, MaxHospitals:0},
{EntityID:394, Name:"HCS2007", City:"ffdf, ", HospitalCount:1, MaxHospitals:0},
{EntityID:396, Name:"HCS2007", City:"ffdf, ", HospitalCount:1, MaxHospitals:0},
{EntityID:398, Name:"HCS2007A", City:"11, ", HospitalCount:1, MaxHospitals:0},
{EntityID:400, Name:"hcs2007b", City:"2, ", HospitalCount:1, MaxHospitals:0},
{EntityID:365, Name:"hcs777", City:"a, ", HospitalCount:3, MaxHospitals:0},
{EntityID:363, Name:"hcu 3", City:"w bloomfield, ", HospitalCount:1, MaxHospitals:0}
]}
What am I doing wrong?
God, I hate this editor.
13:01

Moderators
30/10/2007

Hello,
You should configure the jsonReader - also try to set repeatitems to false.
Look here:
http://www.trirand.com/jqgridw.....#json_data
Regards
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.
03:02

17/02/2010

I looked at that documentation. Most of it seemed to be about customizing jsonreader, which I don't need to do. In any case, I added the jsonreader section to my configuration and modified my AJAX output to generate the data as an array. It still doesn't load anything.
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true,
cell: "cell",
id: "id",
userdata: "userdata",
subgrid: {root:"rows",
repeatitems: true,
cell:"cell"
}
},
colNames:['HCS ID','HCS Name', 'City','Current Hospitals','Max Hospitals'],
colModel :[
{name:'EntityID', index:'EntityID', hidden:true, key:true},
{name:'Name', index:'Name', width:200},
{name:'CityState', index:'CityState', width:160},
{name:'HospitalCount', index:'HospitalCount', width:130, align:'center'},
{name:'MaxHospitals', index:'MaxHospitals', width:110, align:'center'} ],
caption: 'Select an HCS:',
forceFit:true,
hidegrid:false,
scroll:true,
scrollrows:true,
url:'ajax/GetHcsList.php?name=h',
datatype:'json'
});
total:"1",
page:"1",
records:"23",
rows:[{id:"30", cells:["30", "HCN 2/13 #1", ", ", "1", "0"]}
,{id:"37", cells:["37", "HCN 2/13 #10", ", ", "1", "0"]}
,{id:"38", cells:["38", "HCN 2/13 #11", ", ", "1", "0"]}
,{id:"39", cells:["39", "HCN 2/13 #12", ", ", "1", "0"]}
,{id:"40", cells:["40", "HCN 2/13 #13", ", ", "1", "0"]}
,{id:"31", cells:["31", "HCN 2/13 #2", ", ", "1", "0"]}
,{id:"32", cells:["32", "HCN 2/13 #3", ", ", "1", "0"]}
,{id:"33", cells:["33", "HCN 2/13 #4", ", ", "1", "0"]}
,{id:"34", cells:["34", "HCN 2/13 #6", ", ", "1", "0"]}
,{id:"35", cells:["35", "HCN 2/13 #8", ", ", "1", "0"]}
,{id:"36", cells:["36", "HCN 2/13 #9", ", ", "1", "0"]}
,{id:"29", cells:["29", "HCN1", ", ", "1", "0"]}
,{id:"245", cells:["245", "HCS 101", "111, ", "1", "0"]}
,{id:"246", cells:["246", "HCS 2", "2, ", "1", "0"]}
,{id:"341", cells:["341", "HCS Sept", "lkjfldkjgdlkj, ", "2", "0"]}
,{id:"402", cells:["402", "HCS0509", "kk, ", "1", "1"]}
,{id:"392", cells:["392", "HCS2007", "ffdf, ", "1", "0"]}
,{id:"394", cells:["394", "HCS2007", "ffdf, ", "1", "0"]}
,{id:"396", cells:["396", "HCS2007", "ffdf, ", "1", "0"]}
,{id:"398", cells:["398", "HCS2007A", "11, ", "1", "0"]}
,{id:"400", cells:["400", "hcs2007b", "2, ", "1", "0"]}
,{id:"365", cells:["365", "hcs777", "a, ", "3", "0"]}
,{id:"363", cells:["363", "hcu 3", "w bloomfield, ", "1", "0"]}
]}
14:24

12/02/2010

Hi,
Start with this example grid definiton and expected grid output and modify it to suit your need.
jQuery("#list2").jqGrid({ url:'/list,
width: 1000,
height: "100%",
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[ {name:'id',index:'id', width:55},
{name:'invdate',index:'invdate', width:90,editable:true, editoptions:{size:10}},
{name:'name',index:'name asc, invdate', width:100,editable:true,editoptions:{size:10}}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10,
rowList:[10,20,30],
pager: '#pager2', sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Grid Display" });
Expected Grid JSON input
{"page":"","records":"40","rows":[{"id":"1","cell":["1","2010-30-10","1","250.00","100.00","350.00","Description"]}],{"id":"2","cell":["2","2010-30-10","2","250.00","100.00","350.00","Description"]}],"total":"30"}
Hope this helps,
lupin
Most Users Ever Online: 715
Currently Online:
70 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