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

Solution For this…

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nagendra
Top achievements
Rank 1
nagendra asked on 26 Oct 2010, 01:27 PM

I am new to telerik. I want rad grid to work as shown in screen shot. Please provide me solution…

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Oct 2010, 07:21 AM
Hello,

I guess you are using EditCommandColumn as the last column in MasterTableView for editing. If so enabling/disabling can be done in the ItemDataBound event as shown below.

<Columns>
    <telerik:GridEditCommandColumn UniqueName="ActionColumn" EditText="Update" UpdateText="Save"
        CancelText="Cancel" HeaderText="Action">
    </telerik:GridEditCommandColumn>


Code:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridDataItem)
     {
         GridDataItem item = (GridDataItem)e.Item;
         if (Convert.ToInt32(item["Amount"].Text) >10000)
         {
             (item["ActionColumn"].Controls[0] as LinkButton).Enabled = false;
         }
     }
 }




-Shinu.
0
Marin
Telerik team
answered on 27 Oct 2010, 07:30 AM
Hi nagendra,

You can disable/hide the expand/collapse button in the ItemDataBound event for the grid in the following way:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem gridDataItem = e.Item as GridDataItem;
            GridColumn amountColumn = gridDataItem.OwnerTableView.GetColumnSafe("Amount");
            if (amountColumn != null && int.Parse(gridDataItem["CompanyName"].Text)<10000)
            {
                TableCell tc = gridDataItem[RadGrid1.MasterTableView.ExpandCollapseColumn];
                //tc.Enabled = false; uncomment if you wish just to disable the button
                tc.Controls[0].Visible=false;            
            }
        }
    }

On the other question if you need to add certain logic when the ExpandCollapse command is executed you can handle this in the ItemCommand event for the grid.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == RadGrid.ExpandCollapseCommandName)
       {
        //insert custom logic here
       }
   }

Let me know how this works for you and if you have any other questions.


Best wishes,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
nagendra
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Marin
Telerik team
Share this question
or