Results 1 to 6 of 6

Thread: Setting "defaultUnit" to use percentage

  1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    3
    Answers
    1

    Default Answered: Setting "defaultUnit" to use percentage

    Hi
    I am setting the height of a control by using .setHeight(10). But I wan the 10 to be represented as a percentage no a pixel size.

    I think I have to change the default from "px" to something, maybe "%" or "pc" - but not sure how to do this in my js class?

    Thanks
    Bert

  2. I will set the control's width like a style syntax, instead of using .setHeight(20)

  3. #2
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    what happens if you use:

    PHP Code:
    this.setHeight('10%'// this because I do not know witch scope is there :-) 

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    3
    Answers
    1

    Default Didn't work

    It looks like the parameter is looking for an int.

    Thus I think defaultUnit needs to be set to use percentage and the value coming in the .setheight(xx) method will be classed as a percentage then?

  5. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    http://docs-origin.sencha.com/extjs/...thod-setHeight

    The new height to set. This may be one of:

    • A Number specifying the new height in the Element's Ext.Element.defaultUnits (by default, pixels).
    • A String used to set the CSS height style.
    • undefined to leave the height unchanged.

    This is the Text I found in the Abstract Class related to all Components - also your Control I think.

    Maybe you try to use parent Method to set Height.

    Or what happens if you try

    PHP Code:
    this.height '50%' 
    within a Method of your Component-Instance ?

    Maybe:

    PHP Code:
    // after constructor or config for example
    afterRender: function(){
            
    this.height '50%';


  6. #5
    Sencha User
    Join Date
    May 2013
    Posts
    3
    Answers
    1

    Default Thanks - that sorted it

    I will set the control's width like a style syntax, instead of using .setHeight(20)

  7. #6
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6

    Default

    I would be happy if you select my Answer as "best answer" and vote up - because I love it

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
  •