MVC Grid sort on editortemplate dropdownlist column

1 Answer 53 Views
DropDownList Grid
Cynthia
Top achievements
Rank 1
Iron
Cynthia asked on 22 Jan 2026, 10:05 PM
Hi, I'm asking about an answer posted in the Sorting Grid on Editor Template column post back in 2017.  The answer was from Georgi and here is the excerpt: 

public ActionResult Read([DataSourceRequest] DataSourceRequest request) { // Check if any sorts have been applied.if (request.Sorts != null) { // Loop through each sort.foreach (var sort in request.Sorts) { // Check if the Category column is being sortedif (sort.Member == "Category") { // Sort by the CategoryName instead of the Object. sort.Member = "Category.CategoryName"; } } } }

 

My grid column coincidentally also has to do with categories. I tried adding the above code to my read method and it doesn't work. When I click on the header to sort the column it doesn't automatically initiate a read call so I'm not sure how this could work. I guess I'm missing something.

My grid definition:

@(
Html.Kendo().Grid<LookupItem>()
    .Name("LookupList")
    .Columns(columns =>
    {
        columns.Bound(m => m.Id).Hidden(true);
        columns.Bound(m => m.CategoryListItem).ClientTemplate("#: CategoryListItem.CategoryName #").EditorTemplateName("LookupCategoryDropDown").Width("25%"); ;
        columns.Bound(m => m.Name).Width("25%");
        columns.Bound(m => m.Value).Width("15%");
        columns.Bound(m => m.AlternativeValue).Width("15%");
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
    })
    .ToolBar(toolbar => { toolbar.Create().Text("Add New Lookup Item"); })
    .Editable(editable => editable.Mode(GridEditMode.InLine).DisplayDeleteConfirmation("Are you sure you want to delete this item?"))
    .Sortable()
    .Scrollable()
    .Filterable(filterable => filterable.Extra(false))
    .Pageable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(m => m.Id);
            model.Field(m => m.Category);
            model.Field(m => m.Name);
            model.Field(m => m.Value);
            model.Field(m => m.AlternativeValue);

        })
        .Read(read => read.Action("Lookup_Read", "Lookup"))
        .Create(create => create.Action("Lookup_Create", "Lookup"))
        .Update(update => update.Action("Lookup_Update", "Lookup"))
        .Destroy(read => read.Action("Lookup_Delete", "Lookup"))
    )

My Controller Read Method:

 public async Task<IActionResult> Lookup_Read([DataSourceRequest] DataSourceRequest request)
 {
     if (request.Sorts != null)
     {
         // Loop through each sort.
         foreach (var sort in request.Sorts)
         {
             // Check if the Category column is being sorted
             if (sort.Member == "CategoryListItem")
             {
                 // Sort by the CategoryName instead of the Object.
                 sort.Member = "CategoryListItem.CategoryName";
             }
         }
     }
     var model = await _service.GetAllLookupTypesAsync();
     var result = model.ToDataSourceResult(request);
     return Json(result);

 }               

1 Answer, 1 is accepted

Sort by
0
Accepted
Anton Mironov
Telerik team
answered on 27 Jan 2026, 10:48 AM

Hello Cynthia,

Thank you for the code snippets and the details provided.

Yes, you are totally correct - the Read method is not called at sort, because the server operations are disabled in your DataSource:

.ServerOperation(false)
Can you please set it to true and test if the Read method is now called on sort?

Looking forward to hearing back from you.

 

Kind Regards,
Anton Mironov
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.

Cynthia
Top achievements
Rank 1
Iron
commented on 30 Jan 2026, 09:39 PM

That worked!

Thank you!

Anton Mironov
Telerik team
commented on 04 Feb 2026, 09:41 AM

Hi Cynthia,

Thank you for the kind words.

If additional information or assistance is needed, do not hesitate to contact me and the Team.

 

Best Regards,
Anton Mironov

Tags
DropDownList Grid
Asked by
Cynthia
Top achievements
Rank 1
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or