如何从Extjs4中的存储中获取字段类型?
我不会在 Extjs4 中获取存储字段类型,
此代码在 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
,但上面的代码在 Extjs4 中不起作用,它给出未定义的错误,
所以如何知道存储字段类型
,我的痛处是
var data_sample = new Ext.data.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");
}
这在 ie 浏览器年份给我错误为空
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.data.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以访问数据,例如
我在存储对象中找不到类型属性,但是
您可以通过执行以下操作来获取类型,
您将获得类型编号,而不是获取类型 int。
仍然保留模型中定义的类型,因为它将数据转换为正确的类型。因此,如果销售数据为“1000”,它将变成 1000
You can access the data like,
I couldn't find the type property in the store object, but
you can get the type by doing,
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