Hi
I've taken an example from the demo's site, to hide the expand button and add it into an existing column alongside the text.
using this code which is run from RadGrid1_ItemDataBound
But this code was for the selfHierarchy demo. I have 6 inner details tables each within each other like so
So i need to know how i can rewrite the CreateExpandCollapseButton for the detailtables and how to hide the default expand column within the details table.
Assuming something like this
Thanks for any assistance.
Matt
I've taken an example from the demo's site, to hide the expand button and add it into an existing column alongside the text.
using this code which is run from RadGrid1_ItemDataBound
public void CreateExpandCollapseButton(GridItem item, string columnUniqueName, String ButtonColumn) { if (item is GridDataItem) { if (item.FindControl("MyExpandCollapseButton") == null) { Button button = new Button(); button.Click += new EventHandler(button_Click); button.CommandName = "ExpandCollapse"; button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand"; button.ID = "MyExpandCollapseButton"; if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client) { string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID); button.OnClientClick = script; } int level = item.ItemIndexHierarchical.Split(':').Length; if (level > 1) { button.Style["margin-left"] = level * 5 + "px"; } TableCell cell = ((GridDataItem)item)[ButtonColumn]; cell.Controls.Add(button); cell.Controls.Add(new LiteralControl(" ")); cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(ButtonColumn).ToString())); } } }But this code was for the selfHierarchy demo. I have 6 inner details tables each within each other like so
<telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound" ShowStatusBar="true" Skin="Office2007" OnItemCreated="RadGrid1_ItemCreated" runat="server" AutoGenerateColumns="true" AllowSorting="true" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection="False" OnColumnCreated="RadGrid1_ColumnCreated" AllowPaging="false" GridLines="None"> <MasterTableView DataKeyNames="HierarchyID, Link, Name" AllowMultiColumnSorting="True" AutoGenerateColumns="true" HorizontalAlign="Right"> <DetailTables> <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="2" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" /> </ParentTableRelation> <DetailTables> <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="3" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" /> </ParentTableRelation> <DetailTables> <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="4" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" /> </ParentTableRelation> <DetailTables> <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="5" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" /> </ParentTableRelation> <DetailTables> <telerik:GridTableView DataKeyNames="HierarchyID, Link, Name" Name="6" Width="100%" runat="server" AutoGenerateColumns="true" HorizontalAlign="Right"> <ParentTableRelation> <telerik:GridRelationFields DetailKeyField="Link" MasterKeyField="HierarchyID" /> </ParentTableRelation> </telerik:GridTableView> </DetailTables> </telerik:GridTableView> </DetailTables> </telerik:GridTableView> </DetailTables> </telerik:GridTableView> </DetailTables> </telerik:GridTableView> </DetailTables> </MasterTableView> </telerik:RadGrid>So i need to know how i can rewrite the CreateExpandCollapseButton for the detailtables and how to hide the default expand column within the details table.
Assuming something like this
Thanks for any assistance.
Matt