Filter Option Not working in ClientTemplate

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

    Posted 28 Jan 2016 Link to this post

          .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 =>
          .Editable(editable => editable.Mode(GridEditMode.InLine))
          .Pageable(pageable => pageable
          .PageSizes(new List<object> { 10, 20, 50, "All" })
          .HtmlAttributes(new { style = "height:600px;" })
          .DataSource(dataSource => dataSource
              .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
    Dimiter Madjarov avatar
    2277 posts

    Posted 29 Jan 2016 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.

    Dimiter Madjarov
    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
Back to Top