View Full Version : Better way to get the CellEditing instance from grid?

12 Jan 2012, 9:42 AM

I have written some code in a controller that will add a model to a store which is visible in a grid.Panel and then automatically starts editing the cell (as in the cell editing example).

However, I am utilizing the Designer to create the grid and because the code output is generated I can't change this. Therefore I cannot reference the cell edit plugin like in the example (var) and can't assign an ID to this object as the Designer doesn't support that property.

So I'm stuck with this in my view:

plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1

If I could assign an ID in the Designer I could reference the CellEditing object through grid.getPlugin(id) but I can't.

So I've created this code below as a work-around. But I find this quite horrible so I was just wondering if anyone knows of a better way to reference it.

var editor = null;
var plugins = grid.plugins;
if (plugins instanceof Array) {
for (var i = 0; i < plugins.length; i++) {
if (Ext.getClassName(plugins[i]) == 'Ext.grid.plugin.CellEditing') {
editor = plugins[i];
else {
if (Ext.getClassName(plugins) == 'Ext.grid.plugin.CellEditing') {
editor = plugins;
if (editor) {
editor.startEditByPosition({ row: 0, column: 0 });

I'm just starting out with ExtJS so I don't know all the ins and outs yet. Can this be done in a neater way?


12 Jan 2012, 10:02 AM
It should be possible to reference the plugin by: grid.editingPlugin

13 Jan 2012, 3:19 AM
It should be possible to reference the plugin by: grid.editingPlugin

Fantastic, thank you very much. I double checked and this property is not in the documentation for grid.Panel, should be though.


10 Feb 2015, 3:32 PM
add a ref

refs: [{
ref: 'myGrid',
selector: 'EvilEmpire.SuperOrg.panel.mega.uber.grid'

and access ref with plugin query. Static typing is so 20th century. If you hate literal strings, so do i; use your constants class you should have created for your application.

var grid = this.getMyGrid(),
editor = grid.getPlugin('cellediting');


This is much better if you are using multiple plugins, or custom plugins. works for any component with a plugin. Remeber plugins are almost like an extension of an existing class without having to actually extend the class, for whatever reasons you might have.