How do I append a PushButton to GridGroupHeaderItem. I see that I can add a button but I would like to keep the current text and also get a value for the button from the command arg if possible.
I can do the following in ItemCreated and ItemDatabound but it does not work as expected. This replaced the header text all together.
I have tried with header.Cells[0].Controls.Add(lnkbtn); and it kinda works but pushes the button onto a new line. I would like the button to the right of the group header text and if possible, all the way to the right side.
Thanks, Marty
I can do the following in ItemCreated and ItemDatabound but it does not work as expected. This replaced the header text all together.
if
(e.Item
is
GridGroupHeaderItem)
{
GridGroupHeaderItem header = (GridGroupHeaderItem)e.Item;
Button lnkbtn =
new
Button();
lnkbtn.ID =
"Button1"
;
lnkbtn.Text =
"Click"
;
header.DataCell.Controls.Add(lnkbtn);
}
I have tried with header.Cells[0].Controls.Add(lnkbtn); and it kinda works but pushes the button onto a new line. I would like the button to the right of the group header text and if possible, all the way to the right side.
Thanks, Marty
5 Answers, 1 is accepted
0
Hi Marty,
In order to achieve the desired goal I recommend replacing the currently used column with a GridTemplateColumn and defining a HeaderTemplate according to your needs(please refer to the following example).
ASPX:
By following the above approach you should be able to both visualize the text and display a button in the header cell.
Regards,
Angel Petrov
Telerik
In order to achieve the desired goal I recommend replacing the currently used column with a GridTemplateColumn and defining a HeaderTemplate according to your needs(please refer to the following example).
ASPX:
<
telerik:GridTemplateColumn
UniqueName
=
"CustomerID"
DataField
=
"CustomerID"
>
<
HeaderTemplate
>
CustomerID text
<
asp:Button
Text
=
"Click"
ID
=
"button1"
runat
=
"server"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<%#Eval("CustomerID")%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

moegal
Top achievements
Rank 1
answered on 10 Mar 2015, 12:41 PM
Angel, thanks but I am looking for the grouping header not the column header.
any suggestions on: GridGroupHeaderItem
Marty
any suggestions on: GridGroupHeaderItem
Marty
0
Hello Marty,
In order to achieve the desired goal for the group headers you can use a GroupHeaderTemplate. Information about it can be found in this help article.
Regards,
Angel Petrov
Telerik
In order to achieve the desired goal for the group headers you can use a GroupHeaderTemplate. Information about it can be found in this help article.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

moegal
Top achievements
Rank 1
answered on 13 Mar 2015, 12:31 PM
Thanks. we are getting closer. I used sample code right from your link.
I have a field named ProductName but the following does not seem to work in <GroupHeaderTemplate>
<asp:Label runat="server" ID="Label3" Text='<%# "Product name: "+Eval("ProductName") %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["ProductName"]) != null)%>'></asp:Label>
The label shows/hides like it should but only reads: "Product Name: "
It should read: "Product Name: Product 1" etc.
The Eval part is not "Eval'ing".
Any ideas?
Marty
I have a field named ProductName but the following does not seem to work in <GroupHeaderTemplate>
<asp:Label runat="server" ID="Label3" Text='<%# "Product name: "+Eval("ProductName") %>'
Visible='<%# ((((GridGroupHeaderItem)Container).AggregatesValues["ProductName"]) != null)%>'></asp:Label>
The label shows/hides like it should but only reads: "Product Name: "
It should read: "Product Name: Product 1" etc.
The Eval part is not "Eval'ing".
Any ideas?
Marty
0

moegal
Top achievements
Rank 1
answered on 13 Mar 2015, 04:05 PM
I figured it out.
I added FieldAlias="Product" to the GridGroupByField and changed Eval("ProductName") to Eval("Product") and it works.
Thanks,
Marty
I added FieldAlias="Product" to the GridGroupByField and changed Eval("ProductName") to Eval("Product") and it works.
Thanks,
Marty