Completed
Last Updated: 14 Mar 2023 12:09 by ADMIN
Kristofer
Created on: 07 Mar 2023 14:25
Category: Grid
Type: Bug Report
0
Frozen/Locked Templated Grid Column not updating when programmatical state changed

Hello,

I seem to have stubled upon a strange bug in TelerikGrid. We have wrapped a TelerikGrid and the Columns are also wrapped to allow special actions.
The bug is present in "raw-telerik-code" as well.

We have an edge case where we have a TelerikGrid and some of its columns should be Locked (Stickied/Frozen) as a default behaviour.
But depending on user interaction we want to change the state. We cannot use a property for each column that we want to be Locked/Unlocked as it should be handled by the GridState.

When the Column is using default behaviour (not Templated), it works as intended. But as soon as you use a <Template> for the Column, the Locked state cannot be changed from the default/supplied value.

TLDR: Programmatically changing the Locked state of a column where the cell is templated will not change the locked state.

I have prepared two REPL examples. One for 3.7.0 as it is what we currently are using, and one for 4.0.1 as to prove that it still exists in the current itteration.

3.7.0
https://blazorrepl.telerik.com/cHEHurlI06olUsJ410


4.0.1
https://blazorrepl.telerik.com/cdYRuBvo07aB6BGY39

 

With best regards

1 comment
ADMIN
Nadezhda Tacheva
Posted on: 14 Mar 2023 12:09

Hi Kristofer,

Thank you for sharing runnable samples of the described behavior!

It looks like the issue you are facing stems from the fact that the columns declaration include a hardcoded "true" value for their Locked property. The difference between the column with no template and the one that has a template is related to the amount of re-renders upon change. When the template is used, the hardcoded "true" value of the Locked column property overrides the locked state that comes from the Grid state.

There are generally two options to handle such a scenario:

  • Control the locked state of the columns entirely through the Grid state.
  • Do not hardcode the Locked property of the column declaration. Bind it to a variable instead.

You've mentioned that you cannot use a property for each column, so my suggestion will be to use the first approach and control the locked columns through the state.

Generally speaking, the Grid exposes an OnStateInit which allows one to set the desired state on initialization. However, the ColumnStates collection will be empty at this stage which will require one to create the column instances.

Instead of doing so, I would recommend setting the desired state in the OnAfterRender(Async) where the Grid will already be initialized and you can get its state. I've modified your sample to demonstrate the approach: https://blazorrepl.telerik.com/cnYxPebm04tFGa8A10.

I hope you will find the above information and example useful to move forward with your application. In the meantime, I am marking this report as "Completed" as the behavior is related to component and framework specifics rather than a bug.

Regards,
Nadezhda Tacheva
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.