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

Hide GridEditCommandColumn for GridTableView

2 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred Mare
Top achievements
Rank 1
Fred Mare asked on 12 Jan 2011, 08:22 AM

Hi

I am trying to hide the GridEditCommandColumn of a GridTableView when the user clicks on the “add new record” commandItem of the GridTableView.

GridEditCommandColumn editColumnMaster = (GridEditCommandColumn)radGridProjects.MasterTableView.GetColumn("masterEditColum");

editColumnMaster.Visible = false;

 

The above code in the item command event of the grid works perfectly to hide the editcolumn of the mastertableview but not the detail table. It seems to me the GridTableView’s editcolumn only hides after the user clicks on save or cancel. The hierarchy load mode of the grid is set to ServerBind and I am using form templates.

 

Thank you

Fred

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Jan 2011, 09:37 AM
Hello Fred,

Check out the following code snippet which shows how to hide the EditCommandColumn in DetailTable when clicking AddNewRecord button in DetailTable.

ASPX:
<telerik:RadGrid>
        . .  .  .  .
       <DetailTables>
          <telerik:GridTableView CommandItemDisplay="Top" Name="DetailTable" >
              <Columns>
                 <telerik:GridEditCommandColumn UniqueName="detailEditColum">
                 </telerik:GridEditCommandColumn>
               </Columns>
       .  .  .  .  .   .  .  .
   </telerik:RadGrid>

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
       if (e.Item.OwnerTableView.Name == "DetailTable")
            {
                GridTableView tableView = (GridTableView)e.Item.OwnerTableView;
                GridEditCommandColumn editColumndetail = (GridEditCommandColumn)tableView.GetColumn("detailEditColum");
                editColumndetail.Visible = false;
            }
    }

Thanks,
Princy.
0
Fred Mare
Top achievements
Rank 1
answered on 13 Jan 2011, 01:48 PM
Thank you very much is works perfectly!
Tags
Grid
Asked by
Fred Mare
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fred Mare
Top achievements
Rank 1
Share this question
or