Kendo grid grouping and sorting groups

0 Answers 173 Views
Grid Sortable
Rijad
Top achievements
Rank 1
Rijad asked on 23 Aug 2023, 01:18 PM

Hello, 

I am grouping the data by field "AccountCategoryName". After that, groups are sorted alphabetically. I want to sort the groups by AccountCategoryName. Is that achievable? Here is the code snippet:

@(
        Html.Kendo().Grid(Model.Data)
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(r => r.BudgetDataID).Visible(false);
            columns.Bound(r => r.AccountCategoryName).Title(BudgetDataRes.AccountCategory);
            columns.Bound(r => r.AccountCategoryID).Visible(false);
            columns.Bound(r => r.BudgetPositionName).Title(BudgetDataRes.BudgetPositionName);
            columns.Bound(r => r.BudgetPositionID).Visible(false);
            columns.Bound(r => r.Year).Title(BudgetDataRes.Year);
            columns.Bound(r => r.PlannedValue).Title(BudgetDataRes.PlannedValueBAM).Format(Constants.KendoGridMoneyFormat);
            columns.Bound(r => r.FinalValue).Title(BudgetDataRes.FinalValueBAM).Format(Constants.KendoGridMoneyFormat);
        })
        .ToolBar(toolBar =>
        {
            toolBar.Save().SaveText(BudgetDataRes.SaveChanges).CancelText(BudgetDataRes.CancelChanges);
            toolBar.Excel().Text(BudgetDataRes.ExcelExport);
        })
        .Editable(r => r.Mode(GridEditMode.InCell))
        .Excel(r => r.AllPages(true))
        .DataSource(ds => ds
            .Ajax()
            .Batch(true)
            .ServerOperation(true)
            .Model(model =>
            {
                model.Id(r => r.BudgetDataID);
                model.Field(r => r.AccountCategoryID).Editable(false);
                model.Field(r => r.AccountCategoryName).Editable(false);
                model.Field(r => r.AccountTypeID).Editable(false);
                model.Field(r => r.BudgetPositionID).Editable(false);
                model.Field(r => r.BudgetPositionName).Editable(false);
                model.Field(r => r.BudgetDataID).Editable(false);
                model.Field(r => r.Year).Editable(false);
                model.Field(r => r.MunicipalityID).Editable(false);
                model.Field(r => r.PlannedValue).Editable(true);
                model.Field(r => r.FinalValue).Editable(false);
            })
            .Update(r => r.Action("SavePlannedValues", "BudgetData"))
            .Sort(r =>
            {
                r.Add("AccountCategoryID").Ascending();
            })
            .Group(groups =>
            {
                groups.Add(r => r.AccountCategoryName);
            })
        )
    )

No answers yet. Maybe you can help?

Tags
Grid Sortable
Asked by
Rijad
Top achievements
Rank 1
Share this question
or