PDA

View Full Version : Migration from 4.1.3 to 4.2



1 Jul 2015, 12:58 AM
Hi,
one of my application is being migrated from 4.1.3 to 4.2.

I am getting errors for setTitle() method of panel (I am using it onload of the store) and update method of view file.

1..Uncaught TypeError: Cannot read property 'update' of undefined
2.Uncaught TypeError: Cannot read property 'setTitle' of undefined

tristan.lee
1 Jul 2015, 2:14 AM
I'm sorry you're having issues with the upgrade. Can you provide the code that you're having issues with so I can work with you in resolving it?

1 Jul 2015, 2:27 AM
/*Store*/
Ext.define('Cms.store.MyCommunityStore', {
extend : 'Ext.data.Store',
storeId : 'MyCommunityStore',
autoLoad: true,
model : 'Cms.model.MyCommunityModel',
proxy : {
type : 'jsonajax',
url : '/CMS-EXTJS-4.1.3/cms/community/list',
extraParams : {
userName : userName,
},
reader : {
type : 'json',
root : 'communityList'
}
},
listeners: {
load: function(_this, records, successful, eOpts ){
var totalcount = _this.getTotalCount();
Ext.defer(function () {
Ext.getCmp('MyCommunities').setTitle('My Communitites <b class="total-members">'+totalcount+'</b>');
}, 100);
}
}
});


I have a dataview attached with this store.
//Ext.getCmp('MyCommunities'),
here 'MyCommunities' is the id of the tabpanel on which i need the title and the view will be rendered inside this tabpanel...

EPV
1 Jul 2015, 2:44 AM
Your errors indicate that you are not able to get a reference to your tabpanel. Is the tabpanel created when you load the store?

On a sidenote Ext.getCmp('id') should not be used ever as id on a div can cause many errors.

Try:

Ext.ComponentQuery.query('xtype-of-your-tabpanel')[0]

Good luck / E

1 Jul 2015, 2:51 AM
actually , it is working perfectly fine with extjs 4.1.3.
but i am getting the error for 4.2

The tabpanel do gets created on store load.



Ext.ComponentQuery.query('xtype-of-your-tabpanel')[0]
for this code, i need to use panel, but i have numerous panels in my application,how can i differentiate among them without id?

EPV
1 Jul 2015, 3:16 AM
I know the (upgrade) feeling;)

How does the create code look like, is that in the same load-listener?

Regarding ComponentQuery you can specify your own xtype/alias on any component:



Ext.define('MyApp.CoolPanel', {
extend: 'Ext.panel.Panel',
alias: ['widget.coolpanel'],
title: 'Yeah!'
});


http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.Class

/ E

1 Jul 2015, 3:40 AM
Ext.define('Cms.view.CommunityWall', {
alias : 'widget.CommunityWall',
extend : 'Ext.tab.Panel',
id:'CommunityWall',
cls : 'my-community-wall',
items : [{
xtype : 'panel',
id : 'MyCommunities',
title : 'My Communities ',
items : [ {

xtype : 'MyCommunityView', //my view whose store i have attached
flex:1
}]
}]
});

EPV
1 Jul 2015, 4:14 AM
You already have a xtype for your tabpanel CommunityWall.


Ext.ComponentQuery.query('CommunityWall')[0]

will get you a reference so you can remove id.

Though, you still have a race condition and I'm interested in where/when the tabpanel is created.

/ E

1 Jul 2015, 4:19 AM
i have multiple panels.
and each panel is created using the xtype:'panel' whose id is 'MyCommunities' for which i am using setTitle().

'CommunityWall' is the id of the entire wall.

EPV
1 Jul 2015, 4:40 AM
I think there's been something lost in translation;)

Lets restart:

1. You want to change the title of a tabpanel which has the xtype MyCommunityView?
If so, you can reference find it with ComponentQuery. And, you should never use id. It could work and may not have anything to do with your current problem.

2. Is the tabpanel created/present when you are loading the store or is it created runtime after the store is loaded? I'm wondering because there seems to be some kind of race condition. That is, you are trying to set a title on something that does not exist (undefined).

/ E

suzuki1100nz
1 Jul 2015, 11:09 AM
i have multiple panels.
and each panel is created using the xtype:'panel' whose id is 'MyCommunities' for which i am using setTitle().



I would start by first removing the use of 'id' in your code as EPV suggested.
This can cause issues with queries as the id can only be used once and you state you have multiple panels with the same id 'MyCommunities'.

If you want to name your components use itemId not id and given the panels different names

1 Jul 2015, 8:53 PM
yes EPV,
I have changed it to itemId as suggested by you.

and the tabpanel is created at first then the view (''MyCommunityView'') is created on load of that store.
so,i think when i use setTitle,the tabpanel is already been created.

13 Jul 2015, 1:04 AM
Can anybody please enlighten on my issue?

Thanx in Advance!!