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

Hiding the Expand Button for a Particular Row

2 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 28 Aug 2012, 07:32 PM
I have a RadGrid control that will have detail tables beneath it.  The HierarchyLoadMode is "ServerOnDemand".  I would like to hide the expand button in the main grid when the first column value for a row is equal to "Total".  Is this possible?

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Aug 2012, 08:47 AM
Hello,

<telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid3_NeedDataSource"
           OnItemDataBound="RadGrid3_ItemDataBound" AllowMultiRowSelection="true" AllowAutomaticInserts="true"
           AllowFilteringByColumn="true" OnPreRender="RadGrid3_PreRender" OnDetailTableDataBind="RadGrid3_DetailTableDataBind">
           <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" ExpandCollapseColumn-Display="false" Name="Parent">
               <Columns>
               <telerik:GridExpandColumn UniqueName="ExapandColumn"></telerik:GridExpandColumn>
                   <telerik:GridBoundColumn HeaderText="ID" DataField="ID" UniqueName="ID">
                   </telerik:GridBoundColumn>
                   <telerik:GridEditCommandColumn>
                   </telerik:GridEditCommandColumn>
               </Columns>
               <DetailTables>
                   <telerik:GridTableView>
                       <Columns>
                           <telerik:GridBoundColumn HeaderText="Name" DataField="Name" UniqueName="Name">
                           </telerik:GridBoundColumn>
                       </Columns>
                   </telerik:GridTableView>
               </DetailTables>
           </MasterTableView>
       </telerik:RadGrid>
protected void RadGrid3_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
   {
 
       dynamic data = new[] {
           new { ID = 1, Name ="Name1"},
           new { ID = 2, Name = "Name2"},
           new { ID = 3, Name = "Name3"}
       };
       RadGrid3.DataSource = data;
 
 
   }
   protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Parent")
       {
           GridDataItem item = e.Item as GridDataItem;
           if (item.GetDataKeyValue("ID").ToString() == "1")
           {
               (item["ExapandColumn"].Controls[0]).Visible = false;
           }
       }
   }
 
   protected void RadGrid3_PreRender(object sender, EventArgs e)
   {
       
   }
   protected void RadGrid3_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
   {
       dynamic data = new[] {
           new { ID = 1, Name ="Name111"},
           new { ID = 2, Name = "Name222"},
           new { ID = 3, Name = "Name333"}
       };
 
       e.DetailTableView.DataSource = data;
   }


Thanks,
Jayesh Goyani
0
Brian
Top achievements
Rank 1
answered on 29 Aug 2012, 01:19 PM
Thank you.  That did it.
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Brian
Top achievements
Rank 1
Share this question
or