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

Select column dissapears in radGrid

2 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
raskarov
Top achievements
Rank 1
raskarov asked on 09 Mar 2012, 07:56 PM
I want to selectively disable checkboxes based on expression. 

I add code to grid prerender to iterate through each GridDataItem and if condition met, I want to disable checkboxes for select column.

my aspx part:
<Columns>
                <telerik:GridClientSelectColumn UniqueName="checkboxColumn">
                </telerik:GridClientSelectColumn>
my code behind
foreach (GridDataItem item in radGrid.MasterTableView.Items)
{
  if (item is GridDataItem)
        {
          for (int i = 1; i < renderedColumns; i++)
            {
                       GridColumn column = radGrid.MasterTableView.RenderColumns[i];
                       Control control = item[column.UniqueName].Controls[0];
                         if (condition==true&&column.uniqueName=="checkboxColumn")
                           {
                      (control as CheckBox).Enabled=false;
                             }

As soon as this code run, the one that had met conditions dissapear from the page, not just getting disabled. 
If I change like:   (control as CheckBox).Enabled=false;  to say: (control as CheckBox).Tooltip="test"; checkboxes also dissapear.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Mar 2012, 05:10 AM
Hello,

Try the following code in ItemDataBound event.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 if (e.Item is GridDataItem)
 {
   GridDataItem item = (GridDataItem)e.Item;
   CheckBox chk = (CheckBox)item["checkboxColumn"].Controls[0];
   if(condition)
   {    
     chk.Enabled = false;
   }
  }
}

-Shinu.
0
raskarov
Top achievements
Rank 1
answered on 12 Mar 2012, 05:48 AM
The same behavior appears when I use the code in ItemDataBound event.
Tags
Grid
Asked by
raskarov
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
raskarov
Top achievements
Rank 1
Share this question
or