Ext.define('uas.view.grid.rowManager.PanelController', { extend: 'Ext.app.ViewController', alias: 'controller.row-manager', onRowInsert: function() { var me = this, grid = me.getView(), selectionModel = grid.getSelectionModel(), currentPosition; if(selectionModel.hasSelection()) { currentPosition = me.getSelectedPosition(); me.insertRow(currentPosition.rowIdx, 1); }else { Ext.toast('未选中行') } }, onRowAdd: function() { this.addRow(1); }, onRowRemove: function() { var me = this, grid = me.getView(), selectionModel = grid.getSelectionModel(), currentPosition; if(selectionModel.hasSelection()) { currentPosition = me.getSelectedPosition(); me.removeRow(currentPosition.rowIdx); }else { Ext.toast('未选中行') } }, getSelectedPosition: function() { var me = this, grid = me.getView(), selectionModel = grid.getSelectionModel(), currentPosition; if(selectionModel.hasSelection()) { currentPosition = selectionModel.getCurrentPosition(); return currentPosition; }else { return null; } }, insertRow: function(idx, num) { var me = this, grid = me.getView(), store = grid.getStore(), datas = []; Ext.Array.each(new Array(num), function() { datas.push({}); }) store.insert(idx, datas); }, addRow: function(num) { var me = this, grid = me.getView(), store = grid.getStore(), datas = []; Ext.Array.each(new Array(num), function() { datas.push({}); }) store.add(datas); }, removeRow: function(idx) { var me = this, grid = me.getView(), store = grid.getStore(); store.removeAt(idx); }, })