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

Customize telerik grid HeaderContextFilterMenu

1 Answer 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
deepti
Top achievements
Rank 1
deepti asked on 22 Jun 2012, 01:11 PM
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



1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 27 Jun 2012, 08:44 PM
Hi,

For more information how to customize the header context menu items refer to the below article:
http://www.telerik.com/help/aspnet-ajax/grid-header-context-menu.html (see how the menu items are accessed in the last section).

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
deepti
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or