Results 1 to 2 of 2

Thread: Updating Ext.form.Slider style dynamically

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    1
    Vote Rating
    0
      0  

    Default Updating Ext.form.Slider style dynamically

    I'm trying to create a simple progress bar, based on Ext.form.Slider. I'd like to change the slider background width, based on a given progress value.

    Here's my current attempt:
    Code:
    Ext.namespace("Ext.ux");
    Ext.ux.ProgressBar = Ext.extend(Ext.form.Slider, {
        fieldCls: 'progress',
        
        initComponent:function () {
            this.addCls('progress');
            Ext.ux.ProgressBar.superclass.initComponent.apply(this, arguments);
        },
    
        setProgress: function(value) {
            // doesn't work:
            this.fieldEl.setStyle({ width: '50%' });
            this.fieldEl.dom.style.width = '100px';
    
            // works:
            this.el.setStyle({ width: '50%' });
        }  
    });
    Ext.reg('progressbarfield', Ext.ux.ProgressBar);
    And the CSS code:
    Code:
    .progress .x-input-slider.x-slider:after {
        /* This also works:
        width: 20%; 
        */
    }
    .progress .x-thumb.x-draggable {
        visibility: hidden;
    }
    The problem is that I can't change the inner div ("fieldEl") width dynamically - it remains the same. I've got no problems setting the width statically (in CSS), or change the parent div width dynamically.

    Is this the correct way to update components dynamically?

    Thanks in advance

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    The fieldEl stuff will work, just the fields use webkit box to display things.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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