PDA

View Full Version : Ext.data.JsonStore mapping problem



itodd
23 Sep 2010, 7:54 AM
I'm playing around with ExtJS using a JSON API provided by an existing application. I am unable to map to deeper values in my JSON object.

When my mapping contains:


{name:"target", mapping:"fields.target.fields.name"}

No data is rendered in my GridPanel. No error is generated either. If I change it to:


{name:"target", mapping:"fields.target"}

My GridPanel renders correctly (with "Object" in the target column).

/analyzer/projects.json returns something along the lines of:


{"result":"ok","messages":[],"start":0,"perpage":15,"order_by":"submitted","sort":"desc","total":472,"data":[
{
"pk": 494,
"model": "analyzer.project",
"fields": {
"requested_by": {
"pk": 1,
"model": "auth.user",
"fields": {
"username": "itodd"
}
}
"description": "testing lambda",
"lc_fasta_file": "uploads/2010/09/23/lambda-test-set-1_lc.fasta",
"target": {
"pk": 1,
"model": "analyzer.target",
"fields": {
"name": "ACK01"
}
},
"submitted": "2010-09-23 10:56:09",
"processed": "2010-09-23 10:57:22",
}
},

...

}

Is it possible to map to fields.target.fields.name?

Edit: From the API docs, it sounds like my attempt should work.

"The mapping is a string containing the javascript expression to reference the data from an element of the data item's root Array. Defaults to the field name."