openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Table Method autoResizeColumn does not consider OData v2 content

Open cwolbert opened this issue 6 years ago • 6 comments

OpenUI5 version: 1.79.0

Browser/version (+device/version): Chrome Version 84.0.4147.105

Steps to reproduce the problem:

  1. Create OData Service
  2. Create sap.ui.table Table based on the OData service
  3. Attach busyStateChange event to table in handler for event afterRendering
  4. If not busy then perform autoResizeColumn for columns of table in event handler for event busyStateChanged

What is the expected result? The columns will be optimized by both header text and OData content

What happens instead? autoResizeColumn only optimizes the column width by header text, OData content is not considered at this point

Any other information? (attach screenshot if possible) I also tried adding an event listener for the event 'dataRecieved' in the event handler for beforeRebindTable and optimized the columns in the dataRecieved event handler and got the same result.

cwolbert avatar Aug 06 '20 14:08 cwolbert

Hi @cwolbert ,

Thank you for your findings. Please provide a working example (JSBin or something like this) that demonstrates a problem. That way we can inspect and eventually fix the issue.

Best Regards, Nikolay Hristov GitHUb dispatcher

NHristov-sap avatar Aug 07 '20 06:08 NHristov-sap

Hi,

I was struggeling with providing a working example but I finally managed. The problem is too complex to add a JSBin example, so I attached a .zip file that contains all the relevant information: autoResizeColumns.zip As a result I get a table that looks like this: grafik However with the automized column widths I would expect it to look like this: grafik

It seems to me that the data is not yet available in the table when the dataRecieved event is fired and therefore the columns are only optimized by their headers.

cwolbert avatar Aug 18 '20 15:08 cwolbert

Hello @cwolbert , Thank you for sharing this finding. I've created an internal incident 2080375378. The status of the issue will be updated here in GitHub. Regards, Diana

Shtilianova avatar Aug 20 '20 12:08 Shtilianova

Hi @cwolbert,

The "autoResizeColumn" method only works with a limited set of controls and only considers the current state of the UI. So you need to catch the right point in time where the cell content is already rendered with the (new) data. I admit that this is not very user-friendly, but that's as much as we can get from this experimental method. You can use the "change" or "dataReceived" event of the binding and add a timeout of a few milliseconds (let's say 10). https://jsbin.com/ruquqomagu/1/edit?html,output

JumpNRun avatar Aug 31 '20 15:08 JumpNRun

But what if I add a timeout of say 10ms and there is a lot of data to be rendered or/and the user has a terribly slow internet connection or/and uses a smartphone. In that case, there is no guarantee that the cell content is rendered in time. So is there really no other way to achieve this? It would make sense to fire a event after the rendering is completed. I would expect this to be afterRendering but as I have mentioned before, the data is not considered at that point either, probably because it hasn't been rendered.

cwolbert avatar Sep 01 '20 08:09 cwolbert

A slow internet connection should not be an issue when using the "dataReceived" event.

Rendering is a synchronous task. The timeout should just make sure that the rendering process has been started before calling "autoResizeColumn". The method should then be called after the rendering process has finished. If the rendering of the cell content is async - maybe some controls update some of their parts async, not sure about that - then the table also has no chance to find out when the rendering of its entire content is really fully completed.

After all, there are reasons why this method is experimental for such a long time. It works quite ok for simple (text) content and client-side data, but for complex cell content and server-side data there are no straightforward solutions for the existing difficulties, or even no solutions as all.

JumpNRun avatar Sep 01 '20 13:09 JumpNRun