infor-design / enterprise-ng

Angular wrappers for IDS Enterprise components
Apache License 2.0
58 stars 83 forks source link

Datagrid: autosizing doesn't work for component column formatters #1591

Open bartlomiej-k opened 11 months ago

bartlomiej-k commented 11 months ago

Describe the bug We have a lookup component that allows users to choose an entry from a DB. This component accepts entry ID as one of its inputs to set its initial value and in such case, this ID will be translated to a chosen record. That means the display value of the component is loaded lazily and it can take a few seconds to resolve.

When a component of this kind is used as a column formatter component in Datagrid and no column size is specified, the autosizing mechanism doesn't work - the column size is determined only by its header and the cell content is ignored. What's suprising, it works correctly when the Datagrid is placed in Contextual Action Panel. The datasource for the grid doesn't change - the component itself keeps the ID value and the text value displayed to the user.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/ids-quick-start-1701-yczvcc
  2. Wait until the Datagrid's associatedProductId column is resolved. Observe the value is clipped.
  3. Click button below the Datagrid to open Contextual Action Panel with the same grid.
  4. Wait until the associatedProductId column is resolved. Observe the column has been stretched and the whole value is displayed.

Expected behavior Column resizes itself after the component value changes, similar to what can be seen in the action panel.

Version

Screenshots Observed: image Expected: image

Platform

tmcconechy commented 11 months ago

Its been tricky to get this to work. It should work better if you set the width of the modal to some specific default (by setting the contents width).

bartlomiej-k commented 11 months ago

In the modal/action panel it works fine, it doesn't work outside of it.

kwolentarski commented 6 months ago

@tmcconechy, could you maybe introduce a method to recalculate specific column width? I see that there are two methods in datagrid: calculateTextWidth and setColumnWidth, but they are both private. You could create something like recalculateColumnWidth, which would take the column id, calculateTextWidth and then setColumnWidth. Then we can trigger that on our side when the value resolves. There is also some recalculation logic in updateCellNode: image But it has this additional condition ((newWidth - this.stretchColumnWidth) > this.stretchColumnDiff) that I don't understand entirely, so some columns would not update their width.