destroy: function() if (this.host) this.host.un('someevent', this.handler, this); delete this.host; this.callParent();
init: function(host) host.myNewMethod = this.myNewMethod.bind(this); , myNewMethod: function() console.log('Called from host component'); extjs plugins
); You can add methods directly to the host instance: destroy: function() if (this
); Ext.define('MyApp.plugin.Clearable', extend: 'Ext.plugin.Abstract', alias: 'plugin.clearable', init: function(field) this.field = field; field.on('afterrender', this.addClearButton, this); , Unlike a component's subclass (e
1. What is an ExtJS Plugin? In ExtJS, a Plugin is a class that encapsulates reusable functionality, which can be dynamically added to a component (like a Grid, Form, or Panel) at runtime or design time. Unlike a component's subclass (e.g., Ext.grid.Panel ), a plugin does not inherit from the host component. Instead, it "plugs into" the component's lifecycle and event system to augment its behavior.
init: function(grid) this.grid = grid; grid.addCls('grid-with-expander'); // Add a new column for expand/collapse grid.reconfigure(grid.getStore(), [ xtype: 'actioncolumn', width: 30, items: [ iconCls: 'x-fa fa-plus', handler: this.toggleRow.bind(this) ] ].concat(grid.getColumns())); if (this.getExpandOnDblClick()) grid.on('itemdblclick', this.onItemDblClick, this); ,