How to Achieve Auto Width Column in sap.ui.table.Table?

ぃ、小莉子 提交于 2019-12-13 08:10:47

问题


I am using sap.ui.table.Table. This table has some very good feature but I am having a tough time to figure out how to set the column to auto width. Currently, all the columns are fixed size but I want something if column A value is small, then auto adjust it rather than having fixed size. Same for if the column value is large, then adjust it to show the value.


回答1:


The control sap.ui.table.Column offers a property called autoResizable by which the user can resize the column width depending on the content of the column's template.

<Column
  autoResizable="true"
  ... 

From API Reference:

Enables auto-resizing of the column on double clicking the resize bar. The width is determined on the widest currently displayed content. It does not consider rows which are currently not scrolled into view.

However, as you can see, it requires user interaction. Doing it without user interaction programmatically can be achieved by using the (currently experimental) API autoResizeColumn from sap.ui.table.Table.

myTable.autoResizeColumn(/*ColumnIndex*/); // experimental!

Here is an example of both approaches: https://embed.plnkr.co/NQpkJo/.



来源:https://stackoverflow.com/questions/46922864/how-to-achieve-auto-width-column-in-sap-ui-table-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!