-
5 Jan 2012 2:14 AM #1
Inconsistent plugins in ExtJS 4
Inconsistent plugins in ExtJS 4
Hi,
I have used tow plugins for GridPanel. One is Ext.grid.plugin.CellEditing and the other is Ext.ux.RowExpander.
When creating GridPanel, I could specify CellEditing plugin as following:
I could not specify the RowExpander plugin in the same manner since it needs reference of the GridPanel instance.plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
]
My questions is that are there any reasons to have such inconsistent plugins?
Thanks
-
5 Jan 2012 4:06 AM #2
I'm not sure what you mean. The RowExpander should be just the same, you shouldn't need a reference to the grid.
Take a look at the code for the demo:
http://dev.sencha.com/deploy/ext-4.0...d-plugins.html
-
5 Jan 2012 4:14 AM #3
The difference is that in case of CellEditing plugin, you can create an instance of the plugin and set it as config option for the GridPanel whereas in case of RowExpander it is not possible.
See the code below:
a) CellEditing:
b) RowExpander:Code:plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }) ]
I hope example above is conveying what I want to say.Code:plugins: [{ ptype: 'rowexpander', rowBodyTpl : [ '<p><b>Company:</b> {company}</p><br>', '<p><b>Summary:</b> {desc}</p>' ] }]
Thanks
Chirag
-
5 Jan 2012 4:28 AM #4
I think I see what you mean. RowExpander needs the grid to be set in the constructor whereas CellEditing only needs it to be set by init time.
The first thing to note is that RowExpander is a UX so you should expect it to be less tidy than a proper part of the framework. I agree it would be better if you could create it separately using Ext.create.
There's a comment in the source of RowExpander that explain why it needs the grid at construction time. It's relying on the grid features mechanism and apparently that must be done before the plugin's init method is called.
The preferred method for creating plugins is to use the config-style. For CellEditing you should really be writing something like this:
Code:plugins: [{ ptype: 'cellediting', clicksToEdit: 1 }]
-
5 Jan 2012 11:06 PM #5


Reply With Quote