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

Filter Option Not working in ClientTemplate

1 Answer 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sourabh
Top achievements
Rank 1
sourabh asked on 28 Jan 2016, 03:45 PM
 
 
 
 
@(Html.Kendo().Grid<AMCUpfrontTracker2.Models.AccountsViewModel>()
      .Name("kGrid")
      .Columns(columns =>
      {
          columns.Bound(c => c.AccountID).Visible(false);
          columns.Bound(p => p.Agency).ClientTemplate("#=Agency.AgencyName#").Width(220);
          columns.Bound(c => c.Advertiser).ClientTemplate("#=Advertiser.AdvertiserName#").Width(220);
          columns.Bound(c => c.AccountName).Width(220);
          columns.Bound(c => c.Net).ClientTemplate("#=Net.Network#").Width(200);
          //columns.Bound(c => c.BuyCode).ClientTemplate("#=BuyCode.BuyCode#").Width(100);
          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
      })
       .ToolBar(toolBar =>
       {
           toolBar.Create();
       })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Scrollable()
      .Pageable(pageable => pageable
      .Refresh(true)
      .PageSizes(new List<object> { 10, 20, 50, "All" })
      .ButtonCount(5))
      .Sortable()
      .Filterable()
      .ColumnMenu()
      .HtmlAttributes(new { style = "height:600px;" })
      .DataSource(dataSource => dataSource
          .Ajax()
          .ServerOperation(false)
          .Events(events => events.Error("grid_error")) // Handle the "error" event
          .Events(events => events.RequestEnd("requestEndHandler"))
         .Model(model =>
         {
             model.Id(p => p.AccountID);
             model.Field(p => p.AccountID).Editable(false);
             model.Field(p => p.Agency).DefaultValue(
                ViewData["defaultAgency"] as AMCUpfrontTracker2.Models.AgencyViewModel);
             model.Field(p => p.Advertiser).DefaultValue(
                ViewData["defaultAdvertiser"] as AMCUpfrontTracker2.Models.AdvertiserViewModel);
             model.Field(p => p.Net).DefaultValue(
                ViewData["defaultNetwork"] as AMCUpfrontTracker2.Models.NetworkViewModel);
             //model.Field(p => p.BuyCode).DefaultValue(
             //   ViewData["defaultBuyCode"] as AMCUpfrontTracker2.Models.BuyCodesViewModel);
         })
 
          .Read(read => read.Action("Accounts_Read", "ManageAccounts").Data("additionalInfo"))
          .Create(create => create.Action("Accounts_Create", "ManageAccounts"))
          .Update(update => update.Action("Accounts_Update", "ManageAccounts"))
          .Destroy(destroy => destroy.Action("Accounts_Destroy", "ManageAccounts"))
      )

 

 

Filter option is working with columns not having clientTemplates like AccountName but not in others.

 
 

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 29 Jan 2016, 01:55 PM

Hello sourabh,

The reason for the issue is that the mentioned columns are bound to complex objects. Any operation like filtering, sorting, grouping etc. is not supported for complex object, but only for flat data set. This is why I would recommend to extract a ViewModel for the Grid, which contains only the needed properties e.g. AgencyName, AdvertiserName etc.

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
sourabh
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or