Unplanned
Last Updated: 04 Oct 2024 15:28 by ADMIN
Harrison
Created on: 17 May 2022 16:07
Category: ComboBox
Type: Feature Request
10
Sort Direction Parameter for Grouping

Hi Telerik Team,

One of the requirements for my team project is that the ComboBox needs to be sorted in descending order to list dates. We need to sort the groups and the options inside the groups.

Ideally, the ComboBox can have a SortDirection parameter that defines the order as SortAscending or SortDescending, and can display the ComboBox groups and options accordingly.

 

===

Admin Edit:

It would be useful if you could disable the default sorting of the groups as well.

3 comments
ADMIN
Nadezhda Tacheva
Posted on: 04 Oct 2024 15:28

Hi Alexey,

Your last post is a duplicate of a private ticket. I already responded to it but I am also pasting the information here for visibility.

Currently, the ComboBox does not support custom sorting of groups directly, and the groups are sorted in ascending order by default. Exposing an option to manage the sort direction of the groups will be tracked with the current request.

For the time being, a possible option is to implement a custom group ordering. As a reference, you may use this article: Custom Grouping Order in Grid for Blazor. It targets the Grid, but you may use a similar approach for the ComboBox.

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.

Alexey
Posted on: 30 Sep 2024 09:44
I use "TelerikComboBox"  with defined property "GroupField" and I pass data to this control using property "Data".
My data list is prepared and sorted by group (which i pass to "GroupField" ) but my custom sorting is ignored by "TelerikComboBox".
"TelerikComboBox" all time show grouped list using inner "ascending order" and ignore my custom order ("sort of the data").
How to fix it?

I need to use my custom order of the groups for "TelerikComboBox" (with defined property "GroupField").

<TelerikComboBox Data="@Data"
                 @bind-Value="@SelectedValue"
                 GroupField="Category.CategoryName"
                 TextField="ProductName"
                 ValueField="ProductId"
                 Placeholder="Select a product">
</TelerikComboBox>

@code {
    public IEnumerable<Product> Data { get; set; }
    public int SelectedValue { get; set; }

    protected override void OnInitialized()
    {
        List<Product> products = new List<Product>();
        
        products.Add(new Product() // I expect FIRST group will "Category 5"
        {
            ProductId = 2,
            ProductName = $"Product {2}",
            Category = new Category() { CategoryId = 5, CategoryName = $"Category 5" }
        });

        products.Add(new Product() // I expect SECOND group will "Category 3"
        {
            ProductId = 1,
            ProductName = $"Product {1}",
            Category = new Category() { CategoryId = 3, CategoryName = $"Category 3" }
        });

        Data = products;
        base.OnInitialized();
    }

    public class Product
    {
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public Category Category { get; set; }
    }

    public class Category
    {
        public int CategoryId { get; set; }
        public string CategoryName { get; set; }
    }
}

And result of code:
ADMIN
Joana
Posted on: 24 May 2022 13:45

Hello Harrison,

Thank you for the request and I am glad that you have managed to achieve the scenario with the OnRead event.

For transparency in the request, the current approach with the OnRead event is to manipulate the GroupDescriptor available in the `DataSourceRequest` argument. More information can be found in the following documentation:

1. General OnRead article

https://docs.telerik.com/blazor-ui/common-features/data-binding/onread

2. ComboBox Grouping 

https://docs.telerik.com/blazor-ui/components/combobox/grouping 

3. GroupDescriptor Api Reference

https://docs.telerik.com/blazor-ui/api/Telerik.DataSource.GroupDescriptor 

https://docs.telerik.com/blazor-ui/api/Telerik.DataSource.DataSourceRequest 

We will further extend the documentation to contain more examples with OnRead. Thank you for the feedback.

Regards,
Joana
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/.