I'm using ASP NET CORE. I have a grid and I enable filtering on a column with .Filterable(). Is there a way to sort the items that appear in the checkbox filter?
EX:
My filter would look like this
A
B
C
And not
B
C
A
When the drop down is displayed.
1 Answer, 1 is accepted
0
Accepted
Alexander
Telerik team
answered on 09 Jun 2023, 02:45 PM
Hi Eric,
Thank you for reaching out.
We have a readily available knowledge base article that tackles such an approach that can be found here:
The knowledge base article relies heavily on wiring to the FilterMenuInit event of the Grid that is fired once the filter menu is instantiated. From there, based on a field evaluation, the Filter Menu's check source is sorted and the checkboxes are then recreated.
Although the sample tackles a Kendo UI for jQuery Grid the same approach can be also incorporated with the Telerik UI for ASP.NET Core Grid incarnation. Here is a Telerik REPL example that illustrates the mentioned above approach:
That being said, if you don't find this option plausible, and if the server-side implementation is mandatory for your requirements, then it is important to specify the data source for the multi-checkbox in order for the sort to work out. Similar to the following example:
Recently, we have introduced a dedicated article that tackles how the MultiCheckBox filters can be sorted particularly for the Telerik UI for ASP.NET Core suite that can be found here:
The approach used within the article relies on the specification of a DataSource for the filtering of an arbitrary column whilst configuring the sort option of the DataSource. Here is an example:
public ActionResult FreightData()
{
var result = gridDataCollection.GroupBy(p => p.Freight).Select(grp => grp.FirstOrDefault());// Creates a projection over the specified group whilst returning a new set of elements.return Json(result);
}
Could you please confirm, whether either of the mentioned above scenarios is present on your premises?
Kind Regards,
Alexander
Progress Telerik
As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
That's a lot to digest, however it seems it will provide a solution. We're not sorting on the server side, so I will look at the client-side filtering. Thank-you for all your suggestions, the great information, and the pointers to the demos!!!