PDA

View Full Version : Same plugin on multiple panels causing issues



infernoz
6 Mar 2012, 9:56 AM
Hello,

I set up a GridPanel with a plugin that specifies 1 click to edit (may choose to make it more). I specified it as follows, and it works without issue:



Ext.define('DMT.view.PersonGeoUnitView' ,{ extend: 'Ext.grid.Panel', alias : 'widget.personGeoUnitView', id: 'personGeoUnitView', title : 'Person Geo Unit Update', store: 'PersonGeoUnitStore', selType: 'cellmodel', plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }) ...... ...... ],

However, when I created another GridPanel and specified the same plugin, as I would like the same functionality in both, I receive the following error when loading my application:

c is not a constructor
(?)(c=null, a=[Object { clicksToEdit=1}])Batch....6736150 (line 6662)
instantiate()ext-debug.js (line 6634)
alias()ext-debug.js (line 2448)
PersonGeoUnitView.js?_dc=1330976736457()Person...6736457 (line 11)

Here is the second GridPanel setup (pretty similar to the first)



Ext.define('DMT.view.OrgStatisticsView' ,{ extend: 'Ext.grid.Panel', alias : 'widget.orgStatisticsView', id: 'orgStatisticsView', title : 'Organization Statistics Update', store: 'OrgStatisticsStore', selType: 'cellmodel' , plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }) ],


I tried moving the definition of Ext.grid.plugin.CellEditing to a different js file and referencing it via a global variable, but get the same error when doing this too. I could try having each panel extend a parent class which defines this plugin behavior, but I'd like to understand why this error is being thrown in the first place.

I also, placed an identical request yesterday, where it seemed that the Sencha docs way of handling adding plugins was incorrect, but then seemed to be valid. (http://www.sencha.com/forum/showthread.php?185185-Same-plugin-on-multiple-panels-causing-issues) In any case I'd like to understand why this error is being thrown in the situation discussed above.

Thanks,

infernoz

mitchellsimoens
6 Mar 2012, 11:32 AM
You shouldn't use Ext.create in Ext.define like that. You should either use config object or define it in a method:


Ext.define('MyClass', {
....
plugins : [
{
ptype : 'plugin type
}
]
});

infernoz
7 Mar 2012, 10:51 AM
Thanks for the response! As mentioned in another thread (http://www.sencha.com/forum/showthread.php?185185-Same-plugin-on-multiple-panels-causing-issues), if using Ext.create in this context is incorrect, perhaps the Sencha documentation shouldnt reference its usage. You'll get less forum posts for sure :)

Thanks,

infernoz

mitchellsimoens
7 Mar 2012, 10:54 AM
To quote myself:


Relooking at it it's ok. It is using Ext.create not Ext.define so it is ok.

You can use Ext.create within another Ext.create but you should not do Ext.create on a property within an Ext.define call.