这里主要是针对grid的编辑时候不同格式进行设置。例如在一列中,前几行需要是combobox后几行需要的是textfield,这时就需要用到上面的方法。
xtype: 'gridbase',
store: _store,
id: 'grid',
autoScroll: true,
plugins: [
{
ptype: 'cellediting',
clicksToEdit: 1,
id: "gaswindowe ditor"
}
],
pagingtoolbar: false,
isLineFeed: true,
columns: {
defaults: {
align: 'center',
sortable: false,
menuDisabled: true,
tdCls: 'myCss',
defaults: {
sortable: false,
menuDisabled: true,
align: 'center',
//默认设置成textfield格式
editor: {
xtype: 'textfield',
}
}
},
items: _gridHeadData,//动态获取表头
},
listeners: {
//监听函数,在点击之前进行监听
beforeedit: function (editor, e, eOpts) {
//进行条件判断,符合条件则设置称combobox
if (e.rowIdx < 13 && e.colIdx === 22 && e.field === "COST_TYPE") {
var genderStore = Ext.create("Ext.data.Store", {
fields: ["Name", "Value"],
data: [
{Name: 1, Value: 1},
{Name: 0, Value: 0}
]
});
e.column.setEditor({
xtype: 'combobox',
displayField: 'Name',
valueField: 'Value',
editable: false,
store: genderStore
});
}else{
//不符合条件的设置称textfield
e.column.setEditor({
xtype: 'textfield',
})
}
}
}
}
效果如下图
这个是下拉框的格式
这个是textfield的格式,都是同一列,由于条件不同输入方式不同
这个是另一种方法,动态获取combobox的store然后进行设置