<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: sap.ui.table.Table: How to optimize column width? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162888#M4547735</link>
    <description>&lt;P&gt;SAP should really provide an event after data is loaded into the table, so resizing  columns can be done. Without this Grid Tables are pretty much useless. Having to manually press a Resize button every time data is loaded is not good user experience.&lt;/P&gt;&lt;P&gt;I thought &lt;STRONG&gt;beforeRebindTable &lt;/STRONG&gt;event would be that event, but it doesn't seem to work, like all other events it seems to be too early.&lt;/P&gt;&lt;P&gt;Has anyone had any luck with &lt;B&gt;beforeRebindTable?&lt;/B&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 14:32:18 GMT</pubDate>
    <dc:creator>RaminS</dc:creator>
    <dc:date>2021-03-25T14:32:18Z</dc:date>
    <item>
      <title>sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaq-p/12162878</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;
  &lt;P&gt;I want to adjust the width of the column to match the width of the content, using sap.ui.table.Table.&lt;/P&gt;
  &lt;P&gt;The controller code is as follows.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;		onInit: function () {
			var oTable = this.byId("table");
			oTable.bindRows({
				path: '/BusinessPartnerSet',
				events: {
					dataReceived: this._adjustColumn.bind(this)
				}
			});
		},
		
		_adjustColumn: function () {
			var oTable = this.byId("table");
			oTable.getColumns().forEach((oColumn, index) =&amp;gt; {
				oTable.autoResizeColumn(index);
			});
		}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The issue is, at the point of dataRecieved event, contents in the table are not yet available.&lt;/P&gt;
  &lt;P&gt;As a result, the columns are adjusted to match the width of the title, wihch is sometimes too small to fit all the content in.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1816901-pyl4u.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Does anybody know which event we can use to adjust columns?&lt;/P&gt;
  &lt;P&gt;Best regards,&lt;/P&gt;
  &lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 00:45:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaq-p/12162878</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-06-17T00:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162879#M4547726</link>
      <description>&lt;P&gt;setTimeout is something you can use or you can try onafterrendering of table&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;oMyTable.addEventDelegate({
   onAfterRendering: function() {
      // Try resizing here.. if the data is loaded
   }
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jun 2020 05:33:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162879#M4547726</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2020-06-17T05:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162880#M4547727</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Try this code as well - in the event after rendering.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var oTe = new sap.ui.table.TablePointerExtension(oTable);
var aColumns = oTable.getColumns();
for (var i = 0; i &amp;lt; aColumns.length; i++) {
  oTe.doAutoResizeColumn(i);
}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 05:38:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162880#M4547727</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2020-06-17T05:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162881#M4547728</link>
      <description>&lt;P&gt;Dear Mahesh,&lt;/P&gt;&lt;P&gt;Thank you for your suggestion. setTimeout worked.&lt;/P&gt;&lt;P&gt;onAfterRendering event was too early to adjust columns, as table contents were not available at this point.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:16:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162881#M4547728</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-06-18T04:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162882#M4547729</link>
      <description>&lt;P&gt;Dear Venkat,&lt;/P&gt;&lt;P&gt;Thank you for your suggestion.&lt;/P&gt;&lt;P&gt;Unfortunatelly, oTe.doAutoResizeColumn(i) didn't resize columns.&lt;/P&gt;&lt;P&gt;I executed this code both after oTable's onAfterRendering (as suggested by Mahesh) as well as view's onAfterRendering event.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:19:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162882#M4547729</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-06-18T04:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162883#M4547730</link>
      <description>&lt;SPAN class="mention-scrubbed"&gt;mioyasutake&lt;/SPAN&gt; i just saw the code, and it looks like onAfterRendering will not be triggered, but another event is triggered, it's a private event, so it's risky to use it&lt;PRE&gt;&lt;CODE&gt;oTable.attachEvent("_rowsUpdated", function() {
///					
				}.bind(this));&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;so for now it looks like setTimeout is on way(which also I don't like it &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; )BR,Mahesh</description>
      <pubDate>Thu, 18 Jun 2020 06:54:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162883#M4547730</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2020-06-18T06:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162884#M4547731</link>
      <description>&lt;P&gt;Hi Mahesh,&lt;/P&gt;&lt;P&gt;Thanks for your comment.&lt;/P&gt;&lt;P&gt;There doesn't seem to be an official way to implement column optimization.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 23:46:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162884#M4547731</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-06-23T23:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162885#M4547732</link>
      <description>&lt;SPAN class="mention-scrubbed"&gt;mioyasutake&lt;/SPAN&gt;, I can't tell for 100 percent that there is no other way, (the only ways i found are the ones that i mentioned here).You could raise an issues in openui5 git, if you want to get expert resolution on this.-Mahesh</description>
      <pubDate>Wed, 24 Jun 2020 07:27:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162885#M4547732</guid>
      <dc:creator>maheshpalavalli</dc:creator>
      <dc:date>2020-06-24T07:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162886#M4547733</link>
      <description>&lt;P&gt;Try this &lt;A href="https://blogs.sap.com/2020/05/22/fiori-element-list-report-adjust-column-size-automatically/" target="test_blank"&gt;https://blogs.sap.com/2020/05/22/fiori-element-list-report-adjust-column-size-automatically/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 19:53:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162886#M4547733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-09-22T19:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162887#M4547734</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;navneet_nair&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your suggestion.&lt;/P&gt;&lt;P&gt;I tried the solution, but BusyStateChanged event was too early to adjust columns.&lt;/P&gt;&lt;P&gt;The columns were adjusted to match the width of the title rather rather than the width of the contents.&lt;/P&gt;&lt;P&gt;I used sap.ui.table.Table in a freestyle app (not list report), which may caused the difference.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mio&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 08:17:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162887#M4547734</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2020-09-23T08:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162888#M4547735</link>
      <description>&lt;P&gt;SAP should really provide an event after data is loaded into the table, so resizing  columns can be done. Without this Grid Tables are pretty much useless. Having to manually press a Resize button every time data is loaded is not good user experience.&lt;/P&gt;&lt;P&gt;I thought &lt;STRONG&gt;beforeRebindTable &lt;/STRONG&gt;event would be that event, but it doesn't seem to work, like all other events it seems to be too early.&lt;/P&gt;&lt;P&gt;Has anyone had any luck with &lt;B&gt;beforeRebindTable?&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 14:32:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162888#M4547735</guid>
      <dc:creator>RaminS</dc:creator>
      <dc:date>2021-03-25T14:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162889#M4547736</link>
      <description>&lt;P&gt;Since the smarttable directly reads data from odata it is usually not possibly to read the data bound to the table unless we access the inner table. In this case "events parameter comes to the rescue.&lt;/P&gt;&lt;P&gt;You can add change, datarequested, datareceived, attachdatastatechange events to the beforerebindtable/beforerebindtableextension (if its a list report) method&lt;/P&gt; 
&lt;PRE&gt;&lt;CODE&gt;onBeforeRebindTableExtension: function (event) {
      
        event.getParameters()["bindingParams"].events = {
            "dataRequested":function(er)
            {
               
            },
            "dataReceived": function (ec) {

ec.getParameter("data")  //this will give the table resultset
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2022 10:45:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/12162889#M4547736</guid>
      <dc:creator>Kishannaicker</dc:creator>
      <dc:date>2022-04-27T10:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: sap.ui.table.Table: How to optimize column width?</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/13616074#M4819455</link>
      <description>&lt;P&gt;hello everyone, any news regarding this topic. I have the same requirement and I tried the code below but it is not working.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alabi_0-1708617143103.png"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/69445i14BC5DBE613FBDF5/image-size/medium?v=v2&amp;amp;px=400" alt="alabi_0-1708617143103.png" title="alabi_0-1708617143103.png" /&gt;&lt;/span&gt;&lt;BR /&gt;when I debug I see that it is not going after line 78 because there is no getColumns function inside oTable.&lt;BR /&gt;Any suggestion please?&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 15:54:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-ui-table-table-how-to-optimize-column-width/qaa-p/13616074#M4819455</guid>
      <dc:creator>alabi</dc:creator>
      <dc:date>2024-02-22T15:54:07Z</dc:date>
    </item>
  </channel>
</rss>

