简体   繁体   中英

How to group in a specific order in Kendo ASP.NET MVC

I have a Kendo Grid in ASP.NET MVC and I've grouped my datas.

@(Html.Kendo().Grid<Correspondent>(Model.Correspondents)
        .Columns(columns =>
        {
            columns.Bound(p => p.Service)
                .Title("Service")
                .Hidden(true);
            
            columns.Bound(p => p.Name)
                .Title("Name")
                .ClientTemplate(RenderCorrespondentName().ToHtmlString());
            
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
            .Group(groups => groups.Add(p => p.Service))
        )
    )

We can see that I'm grouping my datas by service.

Now, and I can't find a way to do it, is to sort thoses services in a specific order: I'd like one service to always come last.

I've seen somewhere that you can specify an order for your grouping if you pass a list of items in the right order. In my case I do not know what I can get in the service: What I know is I might have a service that is null (Or "None") and if so, I'd like to put this group at the end.

Sorry for potential grammatical errors, I hope I was clear enough.

Thanks in advance.

So I suceeded in what I wanted to do in a very cheeky way.

As I saw that the groups where sorted in ascending order I named my specific service "ZZZ" so that he would be at the end of the list, then in JavaScript I find and edit the "ZZZ" in what I wanted, in this case "Other".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM