我有错误Uncaught TypeError: Cannot read property 'items' of undefined
我创建NewEditInfo类型的以下行。
警报显示数组中有值,所以我没有线索..
getNewEditInfo : function () {
var values = {};
var form = this.getForm();
var formValues = form.getValues();
for (var fieldName in formValues)
values[fieldName] = (formValues[fieldName] != "") ? formValues[fieldName] : null;
alert(JSON.stringify(values));
alert(JSON.stringify(formValues));
NewEditInfo = Ext.data.Record.create([{
name : "id",
type : "string"
}, {
name : "hardwareId",
type : "string"
}, {
name : "location",
type : "string"
}, {
name : "active",
type : "string"
}
]);
var newEditInfoInstance = new NewEditInfo({
id : values['idField'],
hardwareId : values['hardwareIdField'],
location : values['location '],
active : values['active']
});
return newEditInfoInstance;
}
有人可以帮忙吗?
答案 0 :(得分:1)
Ext.data.Record.create()
不返回模型类,而是返回新模型实例。
首先,您应该定义自己的模型:
Ext.define('editInfoModel', {
extend: 'Ext.data.Model',
fields: [
{
name : "id",
type : "string"
}, {
name : "hardwareId",
type : "string"
}, {
name : "location",
type : "string"
}, {
name : "active",
type : "string"
}
]
});
然后在您的getNewEditInfo
方法中,您可以创建editInfoModel
的新实例,并按Ext.create()
方法设置记录数据:
var newEditInfoInstance = Ext.create('editInfoModel', {
id : values['idField'],
hardwareId : values['hardwareIdField'],
location : values['location '],
active : values['active']
});