PDA

View Full Version : Ext.Slider.setValue() problem



vocabo
27 Nov 2009, 12:40 PM
Hi,
I have several tabs usign Ext.TabPanel. In one of them there is a Ext.Slider widget. When the tab is visible and I use Ext.Slider.setValue() function everything is working. The problem arise if I use this function when this tab is not visible, i.e. some other tab is active at the moment,
and then select the tab, where the slider is, the value isn't updated and the slider is in initial position.
I will appreciate any help and suggestions,
Thanks!

vocabo
15 Dec 2009, 7:27 AM
If I use ext-all-debug.js, the error is here

// private
getRatio : function(){
var w = this.innerEl.getWidth();
var v = this.maxValue - this.minValue;
return v == 0 ? w : (w/v);
},
in the Ext.Slider class.
this.innerEl is undefined
This error probable occurs because the slider is not visible at this time. There have to be another way this ratio the be calculated, which doesn't rely on the viability of the element.

shoarh
24 Mar 2010, 6:23 AM
If I use ext-all-debug.js, the error is here

// private
getRatio : function(){
var w = this.innerEl.getWidth();
var v = this.maxValue - this.minValue;
return v == 0 ? w : (w/v);
},
in the Ext.Slider class.
this.innerEl is undefined
This error probable occurs because the slider is not visible at this time. There have to be another way this ratio the be calculated, which doesn't rely on the viability of the element.

I met the same question , I sloved like these,
first you need to close the tab which is actived
code like below:


function closeTab(item){
detailPanel.items.each(function(item){
if(item.title.indexOf('??????')>=0){
detailPanel.remove(item);
}
});
}

detailPanel is the panel which contains many tabs,

Chief Vas
28 Jan 2011, 8:22 PM
I have no idea what the previous poster was doing but I was having a similar problem as the OP not with tabs but with collapsed fieldsets. The fieldsets all were started in the collapsed position where Value and MaxValue were set. When the fieldset was expanded the sliders had the correct values in them (if you clicked on them with the mouse, the slider tip showed the correct loaded value) but their position would be wrong. Searching the forum found one suggestion to store the current value, delete the .value then use setValue() to set it. That didn't work for me but using reset() did:

expand : function(ths){
ths.doLayout();

var slider = Ext.getCmp('NL_MsgBox:X_POS_SLDR');
var sldrVal = slider.getValue();
slider.reset();
slider.setValue(sldrVal);

slider = Ext.getCmp('NL_MsgBox:Y_POS_SLDR');
sldrVal = slider.getValue();
slider.reset();
slider.setValue(sldrVal);

slider = Ext.getCmp('NL_MsgBox:Width_SLDR');
sldrVal = slider.getValue();
slider.reset();
slider.setValue(sldrVal);

slider = Ext.getCmp('NL_MsgBox:Height_SLDR');
sldrVal = slider.getValue();
slider.reset();
slider.setValue(sldrVal);
}

doLayout() is used because fieldsets don't get layed out when collapsed, this forces them to get layed out when the fieldset is expanded. The four blocks of code each grab each slider's value, resets the slider then reload the grabbed values back in. I have not tried this with tabs but I'm guessing it's the same problem in that the slider doesn't get changed because it's not visible.