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

Header Text and Header Template

1 Answer 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Myers
Top achievements
Rank 1
Dave Myers asked on 08 Jul 2010, 04:39 PM
I have a grid set up using template columns and would like to specify the header text (for sorting), but would also like to put some markup below the header text.  If I specify a value for header text, and configure the header template...the markup is displayed before the headder text.  Is there a way to get it to display after the header text?  If not, is there a way I could put the header text in the header template so that it will cause a sort when clicked?

<telerik:GridTemplateColumn DataField="OrderName" SortExpression="OrderName" HeaderText="Expense">
<HeaderTemplate>                                          
<asp:DropDownList ID="OrderNameFilterDdl" AutoPostBack="true" OnSelectedIndexChanged="OrderNameFilterDdl_SelectedIndexChanged" runat="server"></asp:DropDownList>
</HeaderTemplate>
<ItemTemplate>
<%# Eval("OrderName") %>
</ItemTemplate>
</telerik:GridTemplateColumn>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2010, 08:07 AM
Hello Dave,

You can achieve this by adding one LinkButton inside HeaderTemplate with CommandName as 'sort' and CommandArgument as the DataField name . Check out the following code snippet.

ASPX:
<telerik:GridTemplateColumn DataField="OrderName" SortExpression="OrderName">
    <HeaderTemplate>
        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="OrderName">Expense</asp:LinkButton>
        <asp:DropDownList ID="OrderNameFilterDdl" AutoPostBack="true" OnSelectedIndexChanged="OrderNameFilterDdl_SelectedIndexChanged"
            runat="server">
        </asp:DropDownList>
    </HeaderTemplate>
    <ItemTemplate>
        <%# Eval("OrderName") %>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy.
Tags
Grid
Asked by
Dave Myers
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or