Filter Option Not working in ClientTemplate

2 posts, 0 answers
  1. sourabh
    sourabh avatar
    2 posts
    Member since:
    Jan 2016

    Posted 28 Jan Link to this post

     
     
     
     
    @(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.

     
     
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 29 Jan Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top