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

Drop down filter in template column

2 Answers 314 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 17 Nov 2016, 12:44 PM

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 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 17 Nov 2016, 12:45 PM
Please note: I need a completely programmatic example i.e. c# code.
0
Eyup
Telerik team
answered on 22 Nov 2016, 09:38 AM
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.
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or