PDA

View Full Version : Problem instantiate widgets



rkonfortes
5 Jun 2013, 6:14 AM
Hey,
It might be a namespace problem,
I can't instantiate my own defined grid which extends Ext.grid.panel.

this is my grid code:

Ext.namespace("Ronen", "Ronen.widgets", "Ronen.widgets.grids"); var define = Ext.define('Ronen.widgets.grids.Customer', { extend: 'Ronen.widgets.grids.Grid', requires: ['Ronen.widgets.grids.Grid'], initComponent: function () { this.store = Ronen.stores.Customer; this.columns = this.buildColumns(); this.callParent(); },
......

this grid contained in this window:
Ext.namespace("Ronen", "Ronen.widgets", "Ronen.widgets.windows"); Ext.define('Ronen.widgets.windows.Customer', { extend: 'Ext.Window', requires: ['Ronen.widgets.grids.Customer', 'Ronen.widgets.forms.Customer'], height: 200, width: 550, border: false, layout: { type: 'hbox', align: 'stretch' }, initComponent: function () { this.items = this.buildItems(); this.buttons = this.buildButtons(); this.callParent(); this.on('afterrender', this.onAfterRenderLoadForm, this); }, buildItems: function () { return [ { xtype: 'Ronen.widgets.grids.Customer',
....

and this is my entry point:
Ext.Loader.setPath('Ronen', 'js'); Ext.onReady(function () { Ext.create('Ronen.widgets.windows.Customer').show(); });


i have undefined name variable in parseNameSpace() which called by instantiate()

what am i doing wrong?

slemmon
7 Jun 2013, 9:22 AM
You shouldn't need to do the Ext.namespace() in this case.
If you do Ext.Loader.setPath('Ronen', 'js') then all of your Ronen namespaced classes should be nested in a peer folder called 'js'. Under that will be folders corresponding to the package names of your classes. So, Ronen.widgets.grids.Customer would be defined in js/widgets/grids/Customer.js.

When the Customer grid is created it'll be called down from that folder path.

Is that how you have your folders / defined classes set up now?

rkonfortes
8 Jun 2013, 11:40 PM
I solved the problem, it was a wrong class name in the Ext.Define().
And just to make it clear - the best practice is not to use namespace in case i'm using setPath()?

slemmon
10 Jun 2013, 4:03 PM
I've not ever had to use Ext.namespace() if I set the path to my namespaced classes in setPaths in the loader config. So, probably doesn't do any harm or anything, but shouldn't be a necessary step provided the loader is pointed to the right folder for the given namespace.