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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Answers
    3976
    Vote Rating
    1381
      0  

    Default

    The fieldEl stuff will work, just the fields use webkit box to display things.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    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
  •