nicolatosi
3 May 2007, 2:25 AM
I've a question about JSONReader:
my application return a data structure like this:
{ "data" :
{ results : 10,
id: "id"
rows : [
{"id":1, "name": "Nicolas", "surname": "Cage"},
...
]
},
"errors":[],
"messages":[],
"success":true,
...
}
the informations that needs JSONReader are under "data" label, and not immediately at first level. In other words, i cannot use the canonical statement
var myReader = new Ext.data.JsonReader({
totalProperty: "results",
root: "rows",
id: "id"
}, RecordDef);
Can i indicate a kind of navigation of json properties, like
totalProperty: "data/results" ?
Thank you v.m.
Nicola
sfwalter
3 May 2007, 3:59 AM
I've a question about JSONReader:
my application return a data structure like this:
{ "data" :
{ results : 10,
id: "id"
rows : [
{"id":1, "name": "Nicolas", "surname": "Cage"},
...
]
},
"errors":[],
"messages":[],
"success":true,
...
}
the informations that needs JSONReader are under "data" label, and not immediately at first level. In other words, i cannot use the canonical statement
var myReader = new Ext.data.JsonReader({
totalProperty: "results",
root: "rows",
id: "id"
}, RecordDef);
Can i indicate a kind of navigation of json properties, like
totalProperty: "data/results" ?
Thank you v.m.
Nicola
First of all, I think you might be missing "comma" after setting the "id" property in your json. On second thought I don't know why even have "id" property coming back in your json. In the reader config you can tell which of the properties in the rows is the "id" property
Try setting totalProperty to "data.results" and root to "data.rows"
nicolatosi
3 May 2007, 5:11 AM
There is no problem for commas.
The totalProperty "data.results" it's not working.
Do you have an idea?
sfwalter
3 May 2007, 5:43 AM
I took your json format and did a quick test. Here is my json outputted from my server:
{ data: { results: 10, id: 'id', rows: [{description:"Get grocery", context:"errand", priority: "A", duedate :"5/3/2007 5:00 pm", completed: false}, {description:"Get grocery1", context:"errand", priority: "A", duedate :"5/3/2007 5:00 pm", completed: false}, {description:"Get grocery2", context:"errand", priority: "C", duedate :"5/3/2007 5:00 pm", completed: true}, {description:"Get grocery3", context:"errand", priority: "B", duedate :"5/3/2007 5:00 pm", completed: false}, {description:"Get grocery4", context:"errand", priority: "B", duedate :"5/3/2007 5:00 pm", completed: true}, {description:"Get grocery5", context:"errand", priority: "A", duedate :"5/3/2007 5:00 pm", completed: false}, {description:"Get grocery6", context:"errand", priority: "C", duedate :"5/3/2007 5:00 pm", completed: false}, {description:"Get grocery7", context:"errand", priority: "A", duedate :"5/3/2007 5:00 pm", completed: false}] } }
The only difference I see in the above from yours is that I have a comma between the "id" and "rows" attribute.
Then here is my reader:
reader: new Ext.data.JsonReader(
{root: 'data.rows', totalProperty: 'data.results', id: 'description'},
[
{name: 'description'},
{name: 'context'},
{name: 'priority'},
{name: 'duedate', type:'date', dateFormat:'n/j/Y h:i a'},
{name: 'completed', type:'boolean'}
]
Once I did that I was able to call getCount() and getTotalCount() and they returned the correct value
[/code]
nicolatosi
3 May 2007, 7:17 AM
thank you very much, it's correct !
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.