PDA

View Full Version : Grid.reconfigure() do not load data!



Felipe-BR
27 Apr 2012, 6:30 AM
Hello all,

I am trying to load data in the grid using metadata format json and grid.reconfigure method.

This is my json from server.


{
"metaData": {
"root": "data",
"fields": [
{
"name": "classificacao"
},
{
"name": "nomedaorganizacao"
},
{
"name": "Fev",
"mapping":"indicadores.mes",
},
{
"name": "soma"
},
{
"name": "porc"
}
],
"columns": [
{
"header": "Classificacao",
"dataIndex": "classificacao",
"id": "idclassificacao",
"sortable": true,
"width": 150
},
{
"header": "Nome da Organização",
"dataIndex": "nomedaorganizacao",
"id": "idnomedaorganizacao",
"sortable": true,
"width": 150
},
{
"header": "Fev",
"dataIndex": "Fev",
"id": "idfev",
"sortable": true,
"width": 150
},
{
"header": "Soma",
"dataIndex": "soma",
"id": "idsoma",
"sortable": true,
"width": 150
},
{
"header": "Porc",
"dataIndex": "porc",
"id": "idporc",
"sortable": true,
"width": 150
}
]
},
"data": [
{
"indicadores": [
{
"mes": "2",
"quantidadeProcesso": "9",
"ano": "2012"
}
],
"nomedaorganizacao": "ÁGUAS DO PARAÍBA S/A",
"codorganizacao": 1,
"classificacao": "0"
},
{
"indicadores": [
{
"mes": "2",
"quantidadeProcesso": "1",
"ano": "2012"
}
],
"nomedaorganizacao": "AUTO VIAÇÃO RIO ITA",
"codorganizacao": 2,
"classificacao": "0"
}
]
}

This is my grid:


gridIndicadores = new Ext.grid.GridPanel({
id : 'nmGridIndicadores',
name : 'nmGridIndicadores',
frame : true,
viewConfig : {
emptyText : 'Os indicadores não foram processados'
},
height : 200,
width : 'auto',
// store: store,
stripeRows : true,
loadMask : true,
autoSizeColumns : true,
columns : [{}]
});

This is my store and model:


var storeDinamico = Ext.create('Ext.data.Store', {
model : 'modeloDinamico',
proxy : {
type : 'ajax',
url : 'indicadoresservletjson',
reader : [{
type : 'json',
root : 'empresas',
totalProperty : 'quantidade',
record : 'indicadores'
}]
}
});

Ext.define('modeloDinamico', {
extend : 'Ext.data.Model',
fields : [{}]
});

And in the my listener:


gridIndicadores
.reconfigure(
storeDinamico,
records[0].store.proxy.reader.jsonData.metaData.colModel);

The Fev column dont load the data. Whats wrong??? :)

mitchellsimoens
1 May 2012, 7:14 AM
Inspect the store, does the Fev field have value in a record?

Felipe-BR
1 May 2012, 8:32 AM
Hii! Thanks for your reply!

It returns empty. I inspected it using firebug.

Object { classificacao="0", nomedaorganizacao="ÁGUAS DO PARAÍBA S/A", Fev="", porc="", soma=""
}

:s

mitchellsimoens
1 May 2012, 8:54 AM
That would tell me the mapping is incorrect in the model so this has nothing to do with the reconfigure

Felipe-BR
1 May 2012, 9:09 AM
Hey! Thanks!

So how would I do?

Felipe.