Unplanned
Last Updated: 15 Jun 2021 09:01 by ADMIN
Chris
Created on: 03 Jun 2021 09:23
Category: Grid
Type: Bug Report
0
Grid stored state does not restore to full grid width

When resizing grid columns so the last column does not reach the right border of the grid (sum of columns width < current grid width), loading stored state (or changing column width property in any way) does not restore the columns width proportionaly to use the full width of the grid.

Note: in this case, the default columns width sum and stored state columns width sum are always inferior to the grid width in order to use proportionality and adapt to every screen size.

 

In our implementation, we made a "Reset columns view" (working exactly as the loading store data), but if the user play arround with the columns as described above), the reset is broken.

 

Reproduce steps:

Using the persisting state exemple available in the doc: https://stackblitz.com/edit/angular-3jdmzy?file=app%2Fapp.component.ts

- Click "Save current state"

- Resize grid columns so the last column does not reach the right border of the grid

- Click "Load saved state", the columns are resized proportionaly of the saved state but on the base of previous columns width sum instead of the full grid width.

3 comments
ADMIN
Dimiter Topalov
Posted on: 15 Jun 2021 09:00

Hi Chris,

Thank you for providing the additional details.

Indeed, the observed behavior differs based on whether the Grid columns are resized manually, and when a new Grid instance with the respective column configuration is created. When a new Grid instance is created (or the columns are not resized manually or through the autoFitColumn/autoFitColumns methods), the Grid column widths work as described in the following documentation article:

https://www.telerik.com/kendo-angular-ui-develop/components/grid/columns/width/

More specifically, the second bullet applies for the discussed use case:

"When all column widths are explicitly set and the cumulative column width is less than the available Grid width, the remaining width is distributed evenly between all columns."

On the other hand, when the Grid columns are resized manually or through the auto-fitting methods, the internal logic enabling the resizing functionality takes precedence over the preset column widths, and the necessary styling is computed and applied as inline styles.

A possible approach to ensure that the LOAD method will behave consistently and yield the same results regardless of whether the component is loaded for the first time, is to recreate the Grid from the incoming settings when the LOAD button is pressed, for example:

https://stackblitz.com/edit/angular-3jdmzy-lcuyvt?file=app%2Fapp.component.ts

Another option is to loop through the DOM <col> elements corresponding to each Grid column, and set their widths programmatically when the Grid is initially loaded, e.g.:

https://stackblitz.com/edit/angular-3jdmzy-brm8jy?file=app%2Fapp.component.ts

I understand that the described limitations and discrepancies and the need of a non-trivial custom implementation can be frustrating, but they are not considered bugs, as this is the expected behavior based on the current Grid implementation (most limitations are coming from using HTML tables internally). We are however aware that providing our customers with a more straight-forward approach to "force" column widths programmatically will prove to be very useful, and this is why I logged the following issue in our public GitHub repository that you can track and comment as necessary:

https://github.com/telerik/kendo-angular/issues/3335

I hope the suggested workarounds can prove useful until we provide a built-in Grid functionality that will allow forcing column widths such that the sum of column widths is less than the Grid width, and I also apologize for all inconvenience caused by the current limitations.

Regards,
Dimiter Topalov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Chris
Posted on: 14 Jun 2021 08:59

Hi,

To elaborate, I changed the stackblitz example to load saved state on init, if it exists.

https://stackblitz.com/edit/angular-3jdmzy-n1k52n?file=app%2Fapp.component.ts

 

- Resize grid columns so the last column does not reach the right border of the grid

- Click the "Save current state" button

- Enlarge a column

- Click the "Load saved state" button: the columns are resized proportionaly of the saved state but on the base of previous all columns width sum

 

- Now if you reload the tab

The saved state is loaded on init, the proportionality of the saved state is indeed reloaded, but now on the full width of the grid.

 

So for the same action "Load saved state" we have 2 different behaviors:
- set the columns width based on the current all columns width sum
- set the columns width based on the full grid width

ADMIN
Dimiter Topalov
Posted on: 10 Jun 2021 08:22

Hi Chris,

Thank you for the example.

I tried to reproduce the described behavior, but could not.

Here is what I tried:

1) I opened the provided stackblitz demo in full screen mode

2) Resized some of the columns:

3) Clicked the Save button

4) Clicked Load button, but did not see any difference in the columns widths:

Can you please elaborate a bit on the exact steps that need to be followed to reproduce the described behavior?

Regards,
Dimiter Topalov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.