Results 1 to 4 of 4

Thread: Ext.Slider.setValue() problem

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    21

    Default Ext.Slider.setValue() problem

    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!

  2. #2
    Sencha User
    Join Date
    Jun 2009
    Posts
    21

    Default

    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.

  3. #3
    Ext User
    Join Date
    Feb 2009
    Location
    Fuzhou Fujian ,China
    Posts
    16

    Default

    Quote Originally Posted by vocabo View Post
    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,

  4. #4

    Default

    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:
    Code:
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •