Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sap.ui.table.Table how to optimize column widths

Tags:

sapui5

I can't find this anywhere. In a sap.ui.table.Table control is it possible to tell it to resize all column widths so that their contents are fully visible? I don't see any property/method either on the table or column instances.

Is it not supported?

Many thanks.

like image 368
Tiago A. Avatar asked May 14 '14 09:05

Tiago A.


2 Answers

You can use autoResizeColumn(colIndex) method

like image 186
Aliaksei Paverany Avatar answered Sep 27 '22 22:09

Aliaksei Paverany


Option 1: setting fixed sizes of columns

var oTable = new sap.ui.table.Table({
    width : "100%",
    selectionMode : sap.ui.table.SelectionMode.None,
    enableColumnFreeze : true,
});

oTable.addColumn(new sap.ui.table.Column({
    template : new sap.ui.commons.TextView({
        text : "{Title}",
        wrapping : true,
        textAlign : sap.ui.core.TextAlign.Begin,
    }),
    enableColumnFreeze : true,
    width : '350px', // also possible in % -> e.g. in ur case '100%'

}));

Option 2: resizable, but showing full column width, I would try to use these properties

  • width : sap.ui.core.CSSSize
  • flexible : boolean (default: true)
  • resizable : boolean (default: true)

like this

oTable.addColumn(new sap.ui.table.Column({
    template : new sap.ui.commons.TextView({
        text : "{Title}",
        wrapping : true,
        textAlign : sap.ui.core.TextAlign.Begin,
    }),
    width : '100%',
    resizable : false,
    flexible : false,
}));

I think its a challenge, I also made it via fixed sizes .. eventually you can define fixed sizes depending on the screen size .. hope to help you.

like image 40
dotchuZ Avatar answered Sep 27 '22 22:09

dotchuZ