/** * This plugin enables a grouping panel above the grid to allow easy grouping. * * It adds the following methods to the grid panel instance: * * - showGroupingPanel * - hideGroupingPanel * * **Note** To be used with a {@link Ext.grid.TreeGrouped} * */Ext.define('Ext.grid.plugin.GroupingPanel', { extend: 'Ext.grid.plugin.BaseGroupingPanel', alias: 'plugin.groupingpanel', requires: [ 'Ext.grid.plugin.grouping.Panel', 'Ext.grid.plugin.header.DragZone', 'Ext.grid.plugin.header.DropZone' ], gridListeners: { initialize: 'onAfterGridRendered', beforeshowcolumnmenu: 'onBeforeShowColumnMenu' }, destroy: function() { var me = this; me.menus = Ext.destroy(me.menus, me.dragZone, me.dropZone); me.callParent(); }, updateGrid: function(grid, oldGrid) { var me = this, header; if (grid) { header = grid.getHeaderContainer(); me.dragZone = new Ext.grid.plugin.header.DragZone(header); me.dropZone = new Ext.grid.plugin.header.DropZone(header); } me.callParent([grid, oldGrid]); }, onBeforeShowColumnMenu: function(grid, column, menu) { var me = this, menuItem = menu.down('#groupingPanel'), panel = me.getBar(); if (!menuItem) { menu.add('-'); menuItem = menu.add({ itemId: 'groupingPanel', handler: 'toggleGroupingPanel', scope: me }); me.menus = menuItem; } // eslint-disable-next-line max-len menuItem.setText(panel.getHidden() ? panel.showGroupingPanelText : panel.hideGroupingPanelText); }, addGroupingPanel: function() { var me = this, grid = me.getGrid(), header = grid.getHeaderContainer(), pos = grid.indexOf(header) || 0, id = grid.getId(), ret; ret = grid.insert(pos, me.getPanel()); ret = ret && ret.length ? ret[0] : ret; ret.dragZone.setGroups(id); ret.dropZone.setGroups(id); me.dragZone.setGroups(id); me.dropZone.setGroups(id); return ret; }});