Hi,
I am using telrik grid having 'EnableHeaderContextFilterMenu' enabled. I want to customize header context filter menu in order to add custom combo box instead of text box in filter menu option. I am using 'GridTemplateColumn' having rad combo box in 'FilterTemplate' as mentioned below:-
<telerik:GridTemplateColumn DataField="UserType" InitializeTemplatesFirst="false"
HeaderText="User Type" HeaderStyle-Width="100px" UniqueName="UserType" SortExpression="UserType"
AllowFiltering="true" AutoPostBackOnFilter="true" FilterControlWidth="80px">
<HeaderTemplate>
<table>
<tr>
<td>
<asp:LinkButton ID="lnkSort2" runat="server" CommandArgument="UserType" CommandName="Sort"
Text="User Type"></asp:LinkButton>
</td>
<td>
<img src="App_Themes/Default/img/fillter_icon.png" style="vertical-align: middle;
margin-left: 5px; cursor: pointer" onclick='ShowColumnHeaderMenu(event,"UserType")'
alt="Show context menu" />
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblUserType" runat="server" Text='<%# Eval("UserType")%>'></asp:Label>
</ItemTemplate>
<FilterTemplate>
<telerik:RadComboBox runat="server" ID="radCmbUserType" DataValueField="UserType"
AutoPostBack="true" DataTextField="UserType" Width="90px">
</telerik:RadComboBox>
</FilterTemplate>
</telerik:GridTemplateColumn>
Below is the function which binds rad combo box with the values:-
private void LoadFilterCombo()
{
if (null != grdAccounts && grdAccounts.MasterTableView.GetItems(GridItemType.Item).Count() > 0)
{
RadComboBox cboUserType = ((RadComboBox)((GridFilteringItem)grdAccounts.MasterTableView.GetItems(GridItemType.FilteringItem)[0])["UserType"].FindControl("radCmbUserType"));
foreach (int index in Enum.GetValues(typeof(CampaignService.UserType)))
{
RadComboBoxItem item = new RadComboBoxItem();
item.Value = index.ToString();
item.Text = Enum.GetName(typeof(CampaignService.UserType), index);
cboUserType.Items.Add(item);
}
}
}
I want this rad combo box to be displayed in 'HeaderContextFilter Menus' instead of default textbox as shown in attached image in order to apply filter as per selected values in combo box.
can you please suggest any solution on this?
Thanks and Regards,
Deepti
I am using telrik grid having 'EnableHeaderContextFilterMenu' enabled. I want to customize header context filter menu in order to add custom combo box instead of text box in filter menu option. I am using 'GridTemplateColumn' having rad combo box in 'FilterTemplate' as mentioned below:-
<telerik:GridTemplateColumn DataField="UserType" InitializeTemplatesFirst="false"
HeaderText="User Type" HeaderStyle-Width="100px" UniqueName="UserType" SortExpression="UserType"
AllowFiltering="true" AutoPostBackOnFilter="true" FilterControlWidth="80px">
<HeaderTemplate>
<table>
<tr>
<td>
<asp:LinkButton ID="lnkSort2" runat="server" CommandArgument="UserType" CommandName="Sort"
Text="User Type"></asp:LinkButton>
</td>
<td>
<img src="App_Themes/Default/img/fillter_icon.png" style="vertical-align: middle;
margin-left: 5px; cursor: pointer" onclick='ShowColumnHeaderMenu(event,"UserType")'
alt="Show context menu" />
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblUserType" runat="server" Text='<%# Eval("UserType")%>'></asp:Label>
</ItemTemplate>
<FilterTemplate>
<telerik:RadComboBox runat="server" ID="radCmbUserType" DataValueField="UserType"
AutoPostBack="true" DataTextField="UserType" Width="90px">
</telerik:RadComboBox>
</FilterTemplate>
</telerik:GridTemplateColumn>
Below is the function which binds rad combo box with the values:-
private void LoadFilterCombo()
{
if (null != grdAccounts && grdAccounts.MasterTableView.GetItems(GridItemType.Item).Count() > 0)
{
RadComboBox cboUserType = ((RadComboBox)((GridFilteringItem)grdAccounts.MasterTableView.GetItems(GridItemType.FilteringItem)[0])["UserType"].FindControl("radCmbUserType"));
foreach (int index in Enum.GetValues(typeof(CampaignService.UserType)))
{
RadComboBoxItem item = new RadComboBoxItem();
item.Value = index.ToString();
item.Text = Enum.GetName(typeof(CampaignService.UserType), index);
cboUserType.Items.Add(item);
}
}
}
I want this rad combo box to be displayed in 'HeaderContextFilter Menus' instead of default textbox as shown in attached image in order to apply filter as per selected values in combo box.
can you please suggest any solution on this?
Thanks and Regards,
Deepti