PDA

View Full Version : record,array,object



thebashi
6 Jul 2007, 12:49 AM
hi everybody,
i have a strange situation. in my application, i have couple type of datastore objects. and everyone has its unique record definition.


var sampleRecDef=new Array();
sampleRecDef[0]='id';
sampleRecDef[1]='name';
sampleRecDef[2]='lastname';
recordDefinitions.add('key',sampleRecDef);//i keep this definition for further use
Ext.data.Record.create(sampleRecDef);

then i use these record object in datastores.
in some point of application, i need an object which has these attributes as its member variables. something like this

var tmp={id:'x',name:'x',lastname:'x'}
and these 'x' values will be set from datastore's records.

i have found kind of a solution, which is creating a string of JSON which is similar to above code. then "eval" ing it. Eval part can be replaced with ext's json utility.
however i dont believe this is best solution.
Is there a better way to do this thing (i dont know how to name it :)

Animal
6 Jul 2007, 2:50 AM
You mean



Ext.data.Record.create(['id', 'name', 'lastname']);


?

The Store's Records contain the object that you want.

Just get a Record from the Store and examine it in Firebug. It has a "data" property who's member variables are named as the field names.

thebashi
6 Jul 2007, 4:49 AM
thanks animal this was exactly what i want.=D>
i think 'data' is not public property, since it cant be seen in api documentation.