1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    1
    Vote Rating
    0
    kshahar is on a distinguished road

      0  

    Default Unanswered: Updating Ext.form.Slider style dynamically

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The fieldEl stuff will work, just the fields use webkit box to display things.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread