Skip to Content
avatar image
Former Member

How to read UI control width interms of pixels

Hi,

I defined a panel with Width as 100% from xml view but from controller , I want to read actual width interms of pixel size to use same pixel width for another control to set its width to clear whitespace.

when I tried to use getWidth() simply, it is giving as 100% . Is there any way to get size in pixels,please share recommendations.

Regards,

Koti Reddy

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    May 23, 2015 at 07:25 PM

    Hi Koti

    Here is an example

    Sample

    -D

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 25, 2015 at 11:12 AM

    Hi Koti,

    Please use jquery function to get the width value in pixel (Highlighted in bold)

    var button = new sap.m.Button({

    icon: 'sap-icon://accept',

    press: function() {

    alert($('#myPanel').width());

    }

    })

    var p = new sap.m.Panel("myPanel",{

    width : '100%',

    content: [

    button

    ]

    });

    Add comment
    10|10000 characters needed characters exceeded

  • May 25, 2015 at 12:01 PM
    Add comment
    10|10000 characters needed characters exceeded