Forum
02:56
17/10/2012
Hi,
During my question about how to re-apply the toolbar filter after the underline data is refreshed from a local js var question asked here , Oleg has provided me an solution:
1 use the combination of datatype:"local" and data:localvar.
Now I am facing a different problem which after a week I was not able to solve.
According to the Jqgrid wiki when using local datasource the default localreader looks like
localReader = {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "id",
userdata: "userdata",
subgrid: {root:"rows", repeatitems: true, cell:"cell"}
}
I found this is not the case. Because in every examples that i can find using dataype:"local", it always uses a straight js array in stead of an js object, looking like this:
{id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
{id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
{id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}];
I have tried using the default localReader (with
) to process
{"id":0,"cell":["val1","val2","val3"]},
{"id":1,"cell":["val1","val2","val3"]}
],
"page":"1",
"total":"1",
"records":"2"
}
with
datatype:"local",
data:locObj
this will not work, because it wont pass the array check in the addlocaldata function. if I change the option to be
data:locObj.rows
I got a grid with correct number of rows but each cell has an empty value. I think that is becasue the addlocaldata function can not handle an array formatted like locObj.rows.
{"id":0,"cell":["val1","val2","val3"]},
{"id":1,"cell":["val1","val2","val3"]}
]
is there a way to actually process a json object (or string) with the datatype:"local" using the customised localreader (in stead of having to re-create an array on the client side)?
Any help is greatly appreciated.
casbby
Most Users Ever Online: 715
Currently Online:
49 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