Unplanned
Last Updated: 25 Jan 2022 12:41 by ADMIN
Eldoir
Created on: 12 Jan 2022 18:46
Category: UI for WPF
Type: Feature Request
1
GridView: Add VisibleColumnCount property

Hello!

I'm in need for a VisibleColumnCount dependency property for RadGridView (or GridViewDataControl I guess).

Just like FrozenColumnCount actually, so I guess this is just a simple dev but I can be wrong?

It would be so helpful, because I have a textbox ("search column with name") that I use to toggle the visibility of the columns in my RadGridView, and I want to do stuff whether there are matching columns (like, displaying a text "No results").

Currently, I'm using a bunch of converters to do the job an it leads to quite ugly and hard-to-maintain code.

Thanks in advance!

Arthur

3 comments
ADMIN
Martin Ivanov
Posted on: 25 Jan 2022 12:37

Hello Arthur,

Thank you for the additional information. We usually prefer to avoid adding properties that don't bring much benefit to the control in order to optimize its performance and keep its API clean. However, this sounds kind of useful, so we are going to approve it (Unplanned status), so it can collect votes that will help us to measure the demand and potential usage. 

In the meantime, you can achieve your requirement by creating a custom RadGridView control and exposing an additional property that you can update on CollectionChange of the Columns collection and on PropertyChanged of the GridViewColumn elements. You can find this approach shown in the attached project. I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
Eldoir
Posted on: 19 Jan 2022 10:59

Hello Martin,

I expect it to be read-only and updated each time the visibility of one of the columns changes.

I guess it should also change if I add dynamically a new column to the grid and it is visible.

That way, I could bind to this property, and especially, I want to know if there are any visible columns or not, so I check if VisibleColumnsCount == 0.

So actually, if this is easier/cleaner for you, I would be fine with a flag like HasVisibleColumns, since I don't need the exact count (yet).

ADMIN
Martin Ivanov
Posted on: 19 Jan 2022 10:52

Hello Arthur,

Can you tell me a bit more about the behavior of the expected property? Should it be read-only and return only the count of the columns? Or do you expect also to set the property and to display lets say the first 5 columns (if the property is set to 5)?

Note that currently, you can easily get the visible columns by checking their IsVisible property. For example:

int visibleColumnsCount = this.gridView.Columns.OfType<GridViewColumn>().Count(x => x.IsVisible);

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.