PDA

View Full Version : [Solved] Is it possible to set dynamically slider maxValue ?



lpastor
28 Aug 2009, 1:31 PM
I have tried that (but don't work) :


{id:'taille_projet', fieldLabel: 'Taille', name: 'taille_projet', hidden:false, width:60, allowBlank: true, listeners: {
change: function(){
Ext.getCmp('slider_avancement').setmaxValue(Ext.getCmp('taille_projet').getValue());
}
}},
{id:'avancement_projet', name: 'avancement_projet', hidden:true, width:30, allowBlank: true, listeners: {
afterrender: function(){
Ext.getCmp('slider_avancement').setValue(Ext.getCmp('avancement_projet').getValue());
}
}},
new Ext.Slider({
id: 'slider_avancement',
fieldLabel: 'Avancement',
width: 214,
increment: 1,
minValue: 0,
maxValue: 25,
triggerAction: 'all',
plugins: new Ext.ux.SliderTip(),
listeners: {
change: function(){
Ext.getCmp('avancement_projet').setValue(this.getValue());
}
}
}),I think it's not possible to do a setmaxValue(), also how can I do that ?

steffenk
28 Aug 2009, 2:11 PM
why don't you read the doc? There is written which methods are available. And it's not.

So you could use cloneConfig with the new value, destroy the slider and insert the clone.

lpastor
29 Aug 2009, 1:18 AM
Thanks Steffenk,

But it's not easy for a newbies to find a solution in the documentation when in all, I read that :


Class Ext.Slider (http://extjs.com/forum/../deploy/dev/docs/source/Slider.html#cls-Ext.Slider)

Slider which supports vertical or horizontal orientation, keyboard adjustments, configurable snapping, axis clicking and animation. Can be added as an item to any container. Perhaps there is other documentation on the slider that I don't know ?

Thank you anyway

Condor
29 Aug 2009, 1:23 AM
It's not in the documentation, but you could try:


var v = slider.getValue(); // remember current value
slider.maxValue = 200; // change max. value
delete slider.value; // force new value
slider.setValue(v); // setting value causes recalculation

lpastor
29 Aug 2009, 1:55 AM
Thank you very much again Condor.

Gradually I learn and I am progressing thanks to you.

It has been several times that you help me much.

If you give me an address Condor, I will send you a package to thank you, my email : [email protected]

The complete solution for other newbies :


{id:'taille_projet', fieldLabel: 'Taille', name: 'taille_projet', hidden:false, width:60, allowBlank: true, listeners: {
change: function(){
//Ext.getCmp('slider_avancement').setmaxValue(Ext.getCmp('taille_projet').getValue());
var v = Ext.getCmp('slider_avancement').getValue(); // remember current value
Ext.getCmp('slider_avancement').maxValue = Ext.getCmp('taille_projet').getValue(); // change max. value
delete Ext.getCmp('slider_avancement').value; // force new value
Ext.getCmp('slider_avancement').setValue(v); // setting value causes recalculation
}
}},
{id:'avancement_projet', name: 'avancement_projet', hidden:true, width:30, allowBlank: true, listeners: {
afterrender: function(){
Ext.getCmp('slider_avancement').setValue(Ext.getCmp('avancement_projet').getValue());
}
}},
new Ext.Slider({
id: 'slider_avancement',
fieldLabel: 'Avancement',
width: 214,
increment: 1,
minValue: 0,
maxValue: 25,
triggerAction: 'all',
plugins: new Ext.ux.SliderTip(),
listeners: {
change: function(){
Ext.getCmp('avancement_projet').setValue(this.getValue());
}
}
}),

steffenk
29 Aug 2009, 2:39 AM
you should save your component before so you don't have to query all the time:

var el = Ext.getCmp('slider_avancement');
and proceed with el

lpastor
29 Aug 2009, 3:12 AM
Yes thanks, good idea Steffenk.