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

Grid / Header Context Filter Menu programatic

1 Answer 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Estanis
Top achievements
Rank 1
Estanis asked on 30 Mar 2011, 12:44 PM
Hello
I have a RadGrid created dynamically in aspx.
Get all the features of the columns of a table in my database and created the radgrid as has been defined.
More or less:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/groupby/defaultcs.aspx

My problem now is that I want to include a filter of this type:

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextfiltermenu/defaultcs.aspx

Do not know how I can dynamically create this part here is done in HTML.


 <HeaderTemplate>
                        <table>
                            <tr>
                                <td>
<asp:LinkButton ID="lnkSort" runat="server" CommandArgument="ShipCity" CommandName="Sort"
Text="Ship city"></asp:LinkButton>

                                </td>
                                <td>
                                    <img src="Img/Menu.gif" style="margin-top: 5px; margin-left: 5px; cursor: pointer"
                                        onclick='ShowColumnHeaderMenu(event,"ShipCity")' alt="Show context menu" />
                                </td>
                            </tr>
                        </table>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCity" runat="server" Text='<%#Eval("ShipCity") %>'></asp:Label>
                    </ItemTemplate>



Can you help? Thanks

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 04 Apr 2011, 08:28 AM
Hello Estanis,

The header context filter menu can be enabled by setting the EnableHeaderContextFilterMenu property of the corresponding table view to true.

The code you posted implements showing the menu by left-clicking on an element that fires a client-side method (as in the ShipCity template column in the demo). To use this approach when creating the grid programmatically, you could create the corresponding header template dynamically in the code-behind and assign it to the HeaderTemplate property of the column.
Please examine the Programmatic creation help topic for additional information.

I hope this helps.

Best wishes,
Mira
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Estanis
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or