Extjs4-将多个行添加到网格的按钮

时间:2018-07-16 19:16:40

标签: javascript extjs extjs4

我有一个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'

});

0 个答案:

没有答案