This is a migrated thread and some comments may be shown as answers.

[Solved] Sort not working on the template column added to the telerik mvc grid

0 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bhavesh
Top achievements
Rank 1
Bhavesh asked on 05 Feb 2013, 11:42 AM
Hi Experts,

I am using Telerik Web MVC (Version : 2012.1.214.340). on my view file I have Telerik grid which is bound using ajax and on this grid I have a template column and all works fine except the sorting does not work.

@(Html.Telerik().Grid(Model)
              .Name("ClientsGrid")
              .DataKeys(keys => keys.Add(s => s.Id))
                                        .DataBinding(binding => binding.Ajax()
                            .Select("GetClientWithStorage", "ClientsGrid", new { filter = "" })
                        )
.Columns(columns =>
 {
      columns.Bound(o => o.Reference).Title("Client ID").Width(100);
      columns.Bound(o => o.Name).Title("Client Name").Width(300);
      columns.Template(@<text> @if (item.Files != null)
      {
            @Math.Round((decimal)(item.Files.Sum(m => m.ContentLength)) / 1024)@(" KB")
      } </text>)
      .Title("Size")
      .ClientTemplate("<#=GetClientTotalSize(Files)#>").Width(100);
})
.Selectable()
.Sortable(sort =>
     sort.OrderBy(
         config => config.Add(x => x.Reference)
      )
)
.Filterable()
.Pageable(p => p.PageSize(14).Enabled(true))
.ClientEvents(x =>
{
     x.OnRowSelected("clientGrid.rowSelected");
     x.OnLoad("clientGrid.onDataBound");
     x.OnDataBound("clientGrid.onDataBound");
     x.OnDataBinding("clientGrid.onDataBinding");
}).Footer(true)

The above template column "size" is sum of the contentLength on the files table for each client.

The sort works fine on other column except the template column added.

Any help will be highly appreciated.

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