PDA

View Full Version : How to retrieve record definition



tdikarim
19 Oct 2011, 11:09 PM
Hi,

I have a grid that is loaded by metadata

i a classic way I have
var MyRecordType = Ext.data.Record.create(['col1', 'col2']);
var myrec = new MyrecordType({"col1":"101", "col2":"1234"});
grid.store.insert(i,myrec);

BUT, I don't want to hard code the record type on the client side
Does exist a way to retrieve them from the store and have the same result in myrec ?

Thanks for your help

tdikarim
21 Oct 2011, 12:19 AM
Here is my solution.



oneRecordDef = Ext.data.Record.create(grid.store.reader.jsonData.metaData.fields);
oneRecordEmpty = new oneRecordDef(grid.store.reader.jsonData.rootDataDefaultValue[0]);

grid.store.insert(i,oneRecordEmpty);


and the json for rootDataDefaultValue is like


"rootDataDefaultValue":[
{
"CIV_ID":"0 ",
"CIV_LANGUE":"'' ",
"CIV_ORDRE":"0",
"CIV_LIBELLE":"''",
"CIV_ID_SEXE":"0",
"CIV_DELETED":"0"
}
],