This is a migrated thread and some comments may be shown as answers.

Showing/Hiding Grid Columns Issue

9 Answers 1600 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 15 May 2020, 05:46 PM

 Hello,

I've replicated the show/hide grid columns feature as per the grid demo.  The only issue i'm having is that "showing" the column results in the column being moved to the end of the grid instead of appearing in the order in which i have it placed in my list of GridColumns.  Is this expected behavior and is there a way to force the columns to stay in the defined order even when they are being hidden and shown?

 

Thank You

Josh F.

9 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 15 May 2020, 06:42 PM

Hi Josh,

You can follow the implementation of a feature that will allow the column order to be "maintained" in this page: https://feedback.telerik.com/blazor/1434835-preserve-column-order-when-showing-hiding-columns-dynamically - you can find the column chooser workaround linked from my last post there. I've also added your Vote to this request to raise its priority.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Joshua
Top achievements
Rank 1
answered on 15 May 2020, 06:55 PM

Marin,

Thank you for the quick response.  I did see that post and don't quite understand how it differs from the code i have.

Am i correct in that it is as simple as by generating the GridColums in a foreach loop, that forces the grid to build the column order from scratch each time?  if so then I'm good to go.

Thanks
Josh F

0
Marin Bratanov
Telerik team
answered on 15 May 2020, 06:58 PM

Hi Josh,

That's what it does - there is one grid that populates a collection of column descriptors. Then, that collection is used to create the actual grid columns. Changing that collection from the first grid causes Blazor to re-render everything in the loop and so the columns have the order they have in the collection.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Jim
Top achievements
Rank 1
Veteran
answered on 02 Sep 2020, 09:30 PM
Are you guys going to create a GridColumnHidden or an attribute on GridColumn so it is hidden?
0
Marin Bratanov
Telerik team
answered on 03 Sep 2020, 08:08 AM

Hi Jim,

The column will get a Visible parameter that toggles whether it renders or not. It will be available in the upcoming 2.17.0 release (planned for mid-September).

 

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Jim
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 11:53 AM
Will the column still exist in memory so we can read from it?
0
Marin Bratanov
Telerik team
answered on 03 Sep 2020, 12:04 PM

That depends on what you mean by that. The column component should not be created and rendered in the HTML output, but the data is still in the view-model so you can use it in the logic.

 

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Jim
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 12:07 PM

Say you have a list of key/value pairs.  You set that up to display in a grid; except, you don't want to display the Key.

When you edit the displayed value, it comes to you in the GridCommandEventArgs in its edited state.

So, if the value is edited, how do I locate which of the key/value pairs in the Data that it belongs to - if I can't get to the Key associated with the edit?

0
Jim
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 01:01 PM
I got the answer.  The args.Item is the complete record; so, I just cast it and pull the Id that I need.  Thanks.
Tags
Grid
Asked by
Joshua
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Joshua
Top achievements
Rank 1
Jim
Top achievements
Rank 1
Veteran
Share this question
or