Drop down filter in template column

3 posts, 0 answers
  1. Richard
    Richard avatar
    18 posts
    Member since:
    May 2012

    Posted 17 Nov 2016 Link to this post

    Hi,

    I have created a template column and bound it to a RadGrid.

    However, I would like to implement drop down filtering on the column as you describe here:

    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

    Can you clarify if this is possible to achieve using a grid template column?

    I raised a support ticket about this back in Feb 2016 and got the following response:

    Hello Richard,

    Thank you for contacting us.

    You can add a RadComboBox control as a filter item of the TemplateColumn the same way as you did with a BoundColumn. Generally you need to implement a FilterItemTemplate and use pretty much the same approach as the one from the demo.

    I hope this information helps. 

    Regards,
    Kostadin 
    Telerik

    I have tried this approach and I get problems. Could you please show me an example or post some code here?

    Here is the definition of my Template column:

                GridTemplateColumn templateColumn = new GridTemplateColumn();
                templateColumn.ItemTemplate = new GenericGridLinkedItemTemplateColumn(columnName, displayName, listName, lookupType, ActiveColumnName, ItemActiveValue, popoverUrl, itemType, headerText.Replace(" ", string.Empty), genericGridUrl, tab);
                templateColumn.UniqueName = columnName;
                templateColumn.HeaderText = headerText;
                templateColumn.AllowFiltering = true;
                templateColumn.CurrentFilterFunction = GridKnownFunction.Contains;
                templateColumn.AutoPostBackOnFilter = true;
                templateColumn.ShowFilterIcon = false;
                templateColumn.DataField = columnName;

    At the moment it renders a text box to filter by, I would like to change it to a dropdown list.
  2. Richard
    Richard avatar
    18 posts
    Member since:
    May 2012

    Posted 17 Nov 2016 Link to this post

    Please note: I need a completely programmatic example i.e. c# code.
  3. Eyup
    Admin
    Eyup avatar
    3740 posts

    Posted 22 Nov 2016 Link to this post

    Hello Richard,

    As you've already mentioned, you want to achieve something similar to the implementation demonstrated in the following live sample:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

    You can also examine the first web site from this post:
    http://www.telerik.com/forums/how-to-persist-dropdownlist-selected-index-and-value-on-postback-from-radgrid-filtertemplate#GW3MyQLmVEmy8XzsmrHzeQ


    As for creating the filter template programmatically, you can use the ItemCreated event handler provided by the grid. I am sending a web site to demonstrate this implementation.

    Regards,
    Eyup
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top