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

Radgrid enable/disable button column on child and/or parent

1 Answer 369 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jisha
Top achievements
Rank 1
Jisha asked on 30 Jun 2011, 03:48 AM

I have a radgrid control (with detail tables) on an aspx page . I have button column on the parent and  the child(detail

tables) as well.

Based on some criteria I have to disable/enable the button column on parent and/or the child.
what is the best way to do it?

To explain further, the parent display the order  and when click on the order it shows the order items for the order.
the button column is to duplicate an order. the button on the parent duplicates the whole order. the button on the child

(order items) duplicates an order with that particular order item.
Please advise the best solution,
Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jun 2011, 09:12 AM
Hello Jisha,

I am not quite sure about your requirement. Here is a code to hide the buttonColumn in in Master and detail table form external button click.
C#:
protected void Button1_Click(object sender, EventArgs e)
   {
       foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
       {
           Button btn = item["ButtonParent"].Controls[0] as Button;
           btn.Visible = false;
           if (item.Expanded)
          {
               GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
               foreach (GridDataItem childitem in tableView.Items)
               {
                   Button btnClild = (Button)childitem["BtnDetail"].Controls[0];
                   btnClild.Visible = false;
               }
          }
       }
   }

aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
   <MasterTableView DataKeyNames="EmployeeID" HierarchyLoadMode="ServerBind"  >
       <Columns>
         <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">
         </telerik:GridBoundColumn>
         <telerik:GridButtonColumn UniqueName="Button3" Text="Button3" ButtonType="PushButton">
         </telerik:GridButtonColumn>
       </Columns>
     <DetailTables>
     <telerik:GridTableView DataKeyNames="TerritoryID" DataSourceID="SqlDataSource2" AutoGenerateColumns="True">
          <Columns>
               <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">
               </telerik:GridBoundColumn>
               <telerik:GridButtonColumn UniqueName="BtnDetail" Text="Button1" ButtonType="PushButton">
               </telerik:GridButtonColumn>
           </Columns>
          <ParentTableRelation>
            <telerik:GridRelationFields DetailKeyField="EmployeeID" MasterKeyField="EmployeeID" />
          </ParentTableRelation>
      </telerik:GridTableView>
     </DetailTables>
   </MasterTableView>
</telerik:RadGrid>

Thanks,
Shinu.
Tags
Grid
Asked by
Jisha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or