Completed
Last Updated: 30 Jun 2023 09:47 by ADMIN
Clark
Created on: 14 Jun 2023 20:55
Category: Grid
Type: Feature Request
0
CheckBoxList filter only for certain columns

Using CheckBoxList filtering changes the filter menu for all columns. I would like to specify CheckBoxList only for certain columns, but that doesn't currently appear to be an easy option.

1) Leave as FilterMenuType "Menu" but implement a custom filter template for the columns I want. That would be the most obvious, but CheckBoxList is not a usable control on its own?

2) Or do the inverse, use FilterMenuType "CheckBoxList" and implement a custom filter template for all the columns where I don't want to use that. Seems like a lot of extra work to manually recreate default filters.

3) I guess I roll my own clone of the CheckBoxList control and use that like #1 on individual columns?

Any chance the CheckBoxList control could be publicly exposed for direct use?

5 comments
ADMIN
Nadezhda Tacheva
Posted on: 30 Jun 2023 09:47

Hi Clark,

You are correct, the Field of the TelerikCheckBoxListFilter must match the name and type of the column field for which this filter is defined.

Your request for having TextField and ValueField parameters for defining how the checkboxes are created makes perfect sense. In fact, this question has been previously raised and we have an existing feature request for this scenario:

DisplayField for TelerikCheckBoxListFilter to allow using IDs for filtering but showing something meaningful to the user

I added your vote there as we prioritize the requested enhancements based on the demand and we track the gathered votes to evaluate that. In addition, you may follow the item to get timely status updates.

For the time being, a possible option is to manually build the checkboxes and their labels as shown here: Grid - Custom Filter Menu (see the FilterMenuTemplate for the FirstName and Country columns).

Regards,
Nadezhda Tacheva
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Clark
Posted on: 23 Jun 2023 14:07

Is it possible to display text labels for the checkboxes different from the actual underlying values? That's where I'm stuck.

Here is an example based on the one you provided where I added a Role column:
https://blazorrepl.telerik.com/mHuUcdPx369efEqw43

The checkboxes for the Role column show the RoleId values but at least the filtering works:

If I change the Field parameter from "RoleId" to "Name", it displays the names by the checkboxes as desired, but filtering is broken:

It seems the limitation is that Field is used both for creating the FilterDescriptor and for specifying the property in Data, as the docs do state Field "must match the name and type of the column field for which this filter is defined".

If the TelerikCheckBoxListFilter had additional TextField and ValueField parameters solely for defining how the checkboxes are created, I think that would be one way to solve it.

ADMIN
Nadezhda Tacheva
Posted on: 21 Jun 2023 15:13

Hello Clark,

Generally speaking, you can specify the desired menu type on column level through the FilterMenuType parameter of the GridColumn. Here is an example where only the first column uses CheckBoxList filtering and the rest of the columns have the standard FilterMenu: https://blazorrepl.telerik.com/QREgmlvy31dTKfZH58.

If you need to customize the default filtering, you can use the FilterMenuTemplate again on column level. To customize the labels of the checkboxes, I can suggest using a FilterMenuTemplate with a FilterMenuTemplate CheckBoxListFilter component that uses custom data - this will allow you to provide the desired collection of items to be rendered in the CheckBoxListFilter.

Take your time to test this option and please let us know if any other questions appear. In the meantime, I am marking this item as "Completed" as the desired behavior can be achieved with the current component functionality.

Regards,
Nadezhda Tacheva
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Clark
Posted on: 14 Jun 2023 22:04

Unfortunately, it looks like I'll have to roll my own anyway, since the column has underlying numeric values while I want to display text. The column has a Template but the checkboxes do not.

For instance, if I have a "User" column I want it to filter on "UserId" behind the scenes but display "UserName". I can display <Template>@context.UserName</Template> but the checkboxes in the filter will show the numeric values.

Clark
Posted on: 14 Jun 2023 21:52
Nevermind, somehow I completely missed:
"To customize the checkbox list behavior, you should use the filter menu template. To help you with that, we have exposed the TelerikCheckBoxListFilter component that you can place inside the FilterMenuTemplate to get the default grid UI."