我有一个Ext.window.Window
,带有一个grid
作为插件的CellEditing
组件。我注意到Add Row
按钮插入了多行,即使我只单击了一次按钮。
如何使用Cell Editor
限制添加到网格的行数?
代码
//Controller
'account_manage_grid button[name="am_add_account"]': {
click: this.addAccountRow
},
addAccountRow: function (grid, record) {
cellEditing.cancelEdit();
var store = Ext.getStore('AccountManage'),
rec = this.activeRecord.data,
newRec = Ext.create('model.Account', {
accountId: null,
accountName: null,
accountTypeName: null,
accountStatusName: null,
accountCategoryName: null,
accountProgressName: 'Incomplete',
deleteAccount: false,
newAccount: true
});
store.insert(0, newRec);
//store.sync();
cellEditing.startEditByPosition({row: 0, column: 0});
},
...
//Grid
tbar: ['->', {
xtype: 'tbspacer'
},
{
xtype: 'tbtext',
text: '',
itemId: 'acc_count'
}, '-', {
text: 'Add Account',
name: 'am_add_account',
tooltip: 'Add Account'
}],
plugins: [cellEditing]
});
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
pluginId: 'cellEditor'
});