PDA

View Full Version : Same plugin on multiple panels causing issues



infernoz
5 Mar 2012, 11:52 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)




chrome://firebug/content/blank.gif

(6662 out of range 193)



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.

Thanks,

infernoz

mitchellsimoens
5 Mar 2012, 11:54 AM
You shouldn't use Ext.create like that. Either use a config object or specify your plugins within a method like initComponent.

infernoz
5 Mar 2012, 12:02 PM
Thanks for the response. Would it be possible to specify an example of setting a plugin using initComponent and using a config object so myself and others can use it for reference?

Thanks,

infernoz

infernoz
5 Mar 2012, 12:53 PM
Also, I copied the example which seems to be the incorrect way to doing this from the ExtJS 4 docs: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.CellEditing . If this is the wrong way of adding a plugin, it may want to be changed in the docs as well.

Thanks,

Jason

mitchellsimoens
5 Mar 2012, 1:00 PM
Been wondering why people have been using Ext.create in the plugins. I have reported that example to get fixed, we are teaching a bad practice with that.

infernoz
5 Mar 2012, 1:09 PM
Its referenced incorrectly here too: http://www.sencha.com/learn/the-grid-component/.

Would it be possible to show the right way of setting this up in this thread using the initComponent or config object?

Thanks,

infernoz

mitchellsimoens
5 Mar 2012, 1:14 PM
Relooking at it it's ok. It is using Ext.create not Ext.define so it is ok.

infernoz
5 Mar 2012, 1:56 PM
Ok great, but why am I getting this error when I specify it as Ext.create in 2 different Panels?:

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)

What is the alternative way of doing this so this error will not come up?

carol.ext
6 Mar 2012, 2:59 PM
I ran into issues with a grid defined with a plugin using Ext.create when I used more than one of the grid. I ended up using the ptype to specify the plugin.


plugins: [{
ptype: 'cellediting',
clicksToEdit: 1
}]

infernoz
7 Mar 2012, 10:49 AM
Thanks carol.ext! Using the config and ptype for the plugins work on multiple panels. Would you happen to know the technical reason why the error stated above occured though? I'd like to understand the inner workings and what is wrong with using Ext.create in this context.

Thanks,

Jason