我的组合框没有显示当我点击添加时出现一个新行,但它显示“Uncaught TypeError:无法读取属性'xtype'的未定义”错误每次都没有显示组合框。请帮我解决这个问题problem.it在extjs 3中工作正常,但我目前正在研究extjs 4
var cond1 = Ext.create('Ext.data.Store', {
fields: ['maint_condition1'],
data : [
['Excellent'],['Poor'],['New'],['good'],['scrap']
]
}
);
var cond2 = Ext.create('Ext.data.Store', {
fields: ['maint_condition2'],
data : [
['Excellent'],['Poor'],['New']
]
}
);
var cond3 = Ext.create('Ext.data.Store', {
fields: ['maint_condition3'],
data : [
['New'],['Excellent']
]
}
);
var cond4 = Ext.create('Ext.data.Store', {
fields: ['maint_condition4'],
data : [
['New'],['Excellent'],['good'],['Poor'],['scrap']
]
}
);
//ready store
//var cb_select2 =new Ext.grid.CheckboxSelectionModel();
//var cb_select2 =new Ext.grid.CheckboxSelectionModel();
var asset_edit = new Ext.form.TextField();
var notes_edit = new Ext.form.TextField();
var date_edit = new Ext.form.DateField({format: 'm/d/Y'});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false,
saveText: 'Save',
listeners: {
afteredit: syncStore
}
});
var cond1_edit = new Ext.form.DateField({format: 'combo'});
//var sm = Ext.grid.getSelectionModel();
//Grid for show data
var grid = Ext.create('Ext.grid.Panel', {
renderTo: document.body,
//renderTo: 'grid1',
extend: 'Ext.form.ComboBox',
plugins:[rowEditing],
frame: true,
height:140,
width:950,
enableColumnMove: false,
store: store,
columns: [
{header: "Asset ID", dataIndex: 'asset_id',readOnly: true},
{header: "Maint. ID", dataIndex: 'id',readOnly: true},
{header: "Date", dataIndex: 'date_',xtype: 'datecolumn',width: 90,
editor: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
minValue: '01/01/2006',
minText: 'Cannot have a start date before the company existed!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
},
{header: "Notes", dataIndex: 'notes',editor: notes_edit},
{header: "Maint_condition1", dataIndex: 'maint_condition1', sortable: true,width: 120,
editor: Ext.create('Ext.form.ComboBox', {
xtype:'combobox',
allowBlank: false,
mode: 'local',
store: cond1,
valueField: 'maint_condition1',
displayField: 'maint_condition1',
triggerAction: 'all',
editable: false
}
)},
{header: "Maint_condition2", dataIndex: 'maint_condition2', sortable: true,width: 120,
editor: Ext.create('Ext.form.ComboBox', {
xtype:'combobox',
allowBlank: false,
mode: 'local',
store: cond2,
valueField: 'maint_condition2',
displayField: 'maint_condition2',
triggerAction: 'all',
editable: false
}
)},
{header: "Maint_condition3", dataIndex: 'maint_condition3', sortable: true,width: 120,
editor: Ext.create('Ext.form.ComboBox', {
xtype:'combobox',
allowBlank: false,
mode: 'local',
store: cond3,
valueField: 'maint_condition3',
displayField: 'maint_condition3',
triggerAction: 'all',
editable: false
}
)},
{header: "Maint_condition4", dataIndex: 'maint_condition4', sortable: true,width: 120,
editor: Ext.create('Ext.form.ComboBox', {
xtype:'combobox',
allowBlank: false,
mode: 'local',
store: cond4,
valueField: 'maint_condition4',
displayField: 'maint_condition4',
triggerAction: 'all',
editable: false
}
)}
],
tbar: [
{
text: 'Add Record',
icon: 'http://localhost/toolbar2/app/webroot/images/table_add.png',
cls: 'x-btn-text-icon',
handler: function()
{
rowEditing.cancelEdit();
var r = Ext.create('User', {
id: 0,
notes: 'New Notes',
asset_id: window.id,
});
store.insert(0, r);
rowEditing.startEdit(0,0);
}
},
{
text: 'Remove Record',
icon: 'http://localhost/toolbar2/app/webroot/images/table_delete.png',
cls: 'x-btn-text-icon',
handler: function() {
var sm = grid.getSelectionModel();
rowEditing.cancelEdit();
store.remove(sm.getSelection());
if (store.getCount() > 0)
{
sm.select(0);
}
}
}]
});
答案 0 :(得分:0)
正如我在上一篇关于你的另一个问题的评论中提到的那样 - 你需要在商店中定义数据类型 - 也就是xtype。除非您隐式定义,否则您的代码不会只知道项目是字符串。