View Full Version : JSON + JsonStore mapping field doesn't work

10 Sep 2009, 5:35 AM
Hi folks!

I'm trying to recover some data from a JSON object with a JsonStore, and in a particulary field I'm trying to mapping some information, but isn't working just in this field. I'm new in Ext, I couldn't find some examples about it so if you guys help me I would apreciate it!
Let me show my code:


"descricao":"Image Logotipo",

and how I'm getting all this stuff on Ext:

var storeParametrosExecucao = new Ext.data.JsonStore({
url: 'urlurl'
,fields: [
{name: 'id'}
,{name: 'nome', type: 'string', sortType: Ext.data.SortTypes.asUCString}
,{name: 'descricao', type: 'string', sortType: Ext.data.SortTypes.asUCString}
,{name: 'valorRecurso', type:'string', mapping: 'valorRecurso.id'}
,sortInfo: {
field: 'nome'
,autoLoad: false

Thx in advance

10 Sep 2009, 5:44 AM
There is nothing wrong with the example you posted.

What exactly is the problem you are having?

10 Sep 2009, 5:49 AM
Condor, when I take this "valorRecurso.id" out of my JsonStore, my grid is rendered with no problem. With this expression it isnt, and I don't know why....

10 Sep 2009, 5:52 AM
Are you sure that every record has a valorRecurso object?

Otherwise you need to use:

{name: 'valorRecurso', type:'string', mapping: 'valorRecurso', convert: function(v){
return v ? v.id : '';

10 Sep 2009, 6:02 AM
Oh! It's true... sometimes the attribute valor will be null, sometimes valorRecurso... that's why it can't render my Grid, hehe.

Thx Condor!