PDA

View Full Version : Problem with update 4.0.2a to 4.0.7



carruno
3 Jan 2012, 2:29 AM
Hi, the new version doesn't works with this code:


var cbYearCombo01_01 = document.getElementById('annee_01_01');
for (i = CurrentYear; i > 2002; --i) {
var item = document.createElement("option");
item.text = i; item.value = i;
cbYearCombo01_01.options.add(item);
}


Chrome responds:


Uncaught TypeError: Cannot read property 'options' of null


And Firebug:

cbYearCombo01_01 is null


This code worked fine with 4.0.2a version, how can I modify this function to add dynamicaly items to html combo?

Thanks!

mitchellsimoens
3 Jan 2012, 6:16 AM
You're not doing anything Ext there it looks like.

carruno
3 Jan 2012, 9:45 AM
In fact "annee_01_01" is an HTML combo included in Ext TabPanel.

This component is rendered when TabPanel_01 is activate. With 4.0.2a version of Ext, I should activate TabPanel like this:
Ext.getCmp('TABpanel_01').setActiveTab(0); and HTML combo is accessible (with getElementById).

With 4.0.7 version, it seems HTML component is not rendered even if TabPanel is activated (by the code), and getElementById returns null value.

What is certain is that with the old version that's works like a charm.


Any idea?

mitchellsimoens
3 Jan 2012, 9:48 AM
We only render one tab at a time. When you click on a tab, it's contents are rendered.

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.tab.Panel-cfg-deferredRender

carruno
3 Jan 2012, 10:08 AM
deferredRender to false don't solve my problem :(

To understand better there is a code:

Main window with TabPanel:


(function() {
Ext.define('windowUI', {
extend: 'Ext.window.Window',
width: 920,
height: 600,
defaults: {
collapsible: true,
split: true,
animFloat: false,
autoHide: false,
useSplitTips: true
},
initComponent: function() {
this.items = [
{
xtype: 'panel',
layout: 'accordion',
activeItem: 0,
height: 540,
items: [
{
xtype:'tabpanel',
id: 'TABpanel_01',
defaults : {border:false, activeTab:0, height: 410, border:false, autoScroll: true},
items:[
{
,id : 'Panel_01_Tab_01'
}
,
{
,id : 'Panel_01_Tab_02'
}
]
}]
}]
,windowUI.superclass.initComponent.call(this);
}
})
})();


Add combo items script:


Ext.getCmp('TABpanel_01').setActiveTab(0);
var cbYearCombo01_01 = document.getElementById('annee_Panel_01_Tab_01');
for (i = CurrentYear; i > 2002; --i) {
var item = document.createElement('option');
item.text = i; item.value = i;
cbYearCombo01_01.options.add(item);
}

Ext.getCmp('TABpanel_01').setActiveTab(1);
var cbYearCombo01_02 = document.getElementById('annee_Panel_01_Tab_02');
for (i = CurrentYear; i > 2002; --i) {
var item = document.createElement("option");
item.text = i; item.value = i;
cbYearCombo01_02.options.add(item);
}