how to get field type from store in Extjs4?
i wont to get store field type in Extjs4
this code is working under Extjs 3.3.2
var f = store.fields.get(id); // store field name in parameter its return object
alert(f.type.type); //its give me data type of that field
but above code is not working in Extjs4 its give error get of undefine
so how to know store field type
my sore is
var data_sample = new Ext.da开发者_如何学Cta.SimpleStore({
fields: [
{name: 'yr', type: 'string'}
,{name: 'sales', type: 'int'}
,{name: 'expenses', type: 'int'}
],
data: [['2004',1000,400],['2005',1170,460],['2006',860,580],['2007',1030,540]]
});
var year = store.data.get(0).get('yr');
if ( year.constructor == (new Date).constructor){
alert("date");
}
this give me error in ie browser year is null
You can access the data like,
var year = data_sample.data.get(id).get('yr');
I couldn't find the type property in the store object, but you can get the type by doing,
var type = typeof year;
Instead of getting type int, you'll get type number.
Still keep the type defined in the model as it will cast the data to the right type. So if data for sales were "1000" it would turn into 1000
精彩评论