| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 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);
- },
- })
|