PDA

View Full Version : Toggle Bug



babar.sajjad
11 Feb 2011, 4:06 AM
I defined toggle control like this


var toggle_meal = new Ext.form.Toggle({
id: 'toggle_me',
label: 'Log Meal',
cls: 'rounded bordAll',
minValue: 0,
maxValue: 1,
value:1
});

when i call toggle_meal.setValue(1); i get this error Uncaught TypeError: Cannot read property 'offsetBoundary' of undefined

Does not know how to set values dynamically in toggle.

stargieg
16 Feb 2011, 3:16 AM
I defined toggle control like this

Does not know how to set values dynamically in toggle.

Is there any solution or workaround for this?

babar.sajjad
16 Feb 2011, 3:34 AM
i call toggle setValue function in panel show listener, like this


myPanel = Ext.extend(Ext.Panel, {
scroll: 'vertical',
layout: 'auto',
cls: 'green-bg',
items: [meal_basic_data_view,toggle_meal,remain_meal_data_view],
listeners:{
show: function(){
toggle_meal.setValue(1);
}
}

});


its working fine now :)

stargieg
16 Feb 2011, 5:46 AM
i call toggle setValue function in panel show listener, like this


myPanel = Ext.extend(Ext.Panel, {
scroll: 'vertical',
layout: 'auto',
cls: 'green-bg',
items: [meal_basic_data_view,toggle_meal,remain_meal_data_view],
listeners:{
show: function(){
toggle_meal.setValue(1);
}
}

});


its working fine now :)
Hm. That does not work for me.
That is my Formpannel.


var formLeft = new Ext.form.FormPanel({
cls: 'cards',
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [{
xtype: 'fieldset',
title: 'DIMMEN',
defaults: {
xtype: 'sliderfield',
labelAlign: 'top',
animate: true,
showAnimation: true,
minValue: 0,
maxValue: 100,
value: 0,
cls: '',
listeners:{
change: function (sliderfield,thumb,oldValue,newValue) {
change_event(sliderfield,thumb,oldValue,newValue);
}
}
},
items: [{
id: '9_bel_de_1_hw_R601',
label: 'Deckenspots Kreis 1'
},
{
id: '10_bel_de_2_hw_R601',
label: 'Pendelleuchte'
},
{
id: '11_bel_de_3_hw_R601',
label: 'Deckenspots Kreis 2'
}]
}]
});


I have a externel script with


window.setTimeout(timer, interval);


and



var element = Ext.getCmp('9_bel_de_1_hw_R601');
oldvalueStr = element.getValue();
console.log('oldvalueStr');
element.setValue(10);


I can not read the value with getValue() and can not write with setValue().

stargieg
17 Feb 2011, 2:45 PM
It works! :-)

I add a listner with setTimout function.



var formLeft = new Ext.form.FormPanel({
cls: 'cards',
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [{
xtype: 'fieldset',
title: 'DIMMEN',
defaults: {
xtype: 'sliderfield',
labelAlign: 'top',
animate: true,
showAnimation: true,
minValue: 0,
maxValue: 100,
value: 0,
cls: '',
listeners:{
afterrender: function(comp) {
setTimeout(timer_el, 1000,comp);
},
change: function (sliderfield,thumb,oldValue,newValue) {
change_event(sliderfield,thumb,oldValue,newValue);
},
},
items: [{
id: '9_bel_de_1_hw_R601',
label: 'Deckenspots Kreis 1'
},
{
id: '10_bel_de_2_hw_R601',
label: 'Pendelleuchte'
},
{
id: '11_bel_de_3_hw_R601',
label: 'Deckenspots Kreis 2'
}]
}]
});


I have a externel script with timer_el()
and successful setValue() end getValue()



function timer_el(elName) {
var elNameStr=elName.getName();
if (vdb[elNameStr]) {
var elNameVal=elName.getValue();
if (elNameVal != vdb[elNameStr]) {
elName.setValue(vdb[elNameStr]);
}
}
setTimeout(timer_el, 1000,elName);
}


THX for the hints

babar.sajjad
17 Feb 2011, 3:11 PM
:) thats gr8