cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Table Column Resizing Methods, Events, Properties

Former Member
0 Kudos

Dear SAPUI5 Experts,

Our goal is to resize the columns according to the string length of the json file data. Currently, following events and methods are available for sap.ui.table:


Event:

columnResize

Method:

autoResizeColumn(iColId)


The sap.ui.colum offers autoResizable(boolean value) doesn´t show any changes. I also do not see major changes if I change the width of the columns to 100%.

My question is: How to implement these methods/events correctly?

Thank you very much in advance!

Best regards,

Rufat

Accepted Solutions (1)

Accepted Solutions (1)

kai2015
Contributor
0 Kudos

AutoResize example here:

JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type=&q...

But the rendering is not the best 🙂

Also notice the API hint:

Experimental API:Experimental! Presently implemented to only work with pure text-based controls, the sap.ui.commons.Checkbox and sap.m.Image as well as sap.ui.commons.Image. It will also work for most simple input fields (TextField, CheckBox, but not ComboBox)

Former Member
0 Kudos

Hi Kai,

Great! Thank you! I implemented this method before, but obviously not the right way, but your example helps me a lot! Many Thanks!

Best regards,

Rufat

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

I am also using "sap.ui.getCore().getElementById("Status_table").autoResizeColumn(0);"

But this code is reducing the column size.

Please Help me.

Thanks

Sudipto

kai2015
Contributor
0 Kudos

And what shall I do without your code?

I can only guess that you are doing something wrong // different.

kedarT
Active Contributor
0 Kudos

Hi Rufat,

I hope you are using sap.m.Table, there is a property "fixedLayout" make this false as it is true by default.

Hope this helps

Former Member
0 Kudos

Hi Kedar,

no, I don´t use the sap.m.table. There are pro´s and contra´s using for usage of sap.m.table and sap.ui.table which made us to choose the proper table for our desktop application. For example, the sap.ui.table didn´t have any properties for column reordering etc. while the sap.m.table offers paging functionalities out of the box....

Best regards,

Rufat

kai2015
Contributor
0 Kudos

Is Auto-Width not enough for you?

There is a lot to do, to set the width by length of characters ...

=> 5 * 'i' has another width than 5 * 'm'

=> than you need to get the maximum length of each column by looping each cell

And the result will be a table with space at the right side (or with too much data, an overflow)

So the best way is auto-width I think.

Former Member
0 Kudos

But where can I find the property auto-width?

I tried setting width to auto, but no resullts....

kai2015
Contributor
0 Kudos

btw a column cannot have a width of 100% if you have more than one column.

All columns together have 100%

Former Member
0 Kudos

..sry, I meant 100px, not percent...and I see changes when I set a column width to a specific width..