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

Radgrid Change the Readonly attribute

3 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony Abou-Akl
Top achievements
Rank 1
Tony Abou-Akl asked on 17 Jul 2009, 02:32 PM
Hi there

I using the radgrid and i'm trying to change the readonly attribute in a cell in the code behind

I'm looping thru the griditm and would like to change the readonly

For

 

Each grdItem As GridDataItem In radResourcesList.MasterTableView.Items

 

 

    If TypeOf grdItem Is GridEditableItem Then

 

 

        Dim editableItem As GridEditableItem = CType(grdItem, GridDataItem)

 

        editableItem.Edit =

True

 

        If bchange = true then
            ' I would like ot change the griditem("attend") readonly attibute from true ot false 
        End If        

        

    

 

 

 

    End If        
Next

you help is appreciated

thanks
Tony

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2009, 05:25 AM
Hi Tony,

You can try the following code snippet in the PreRender event to set a Grid row in edit mode depending on the cell value.

VB:
 
 
    Protected Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As EventArgs) 
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items 
            If item("ProductID").Text = "3" Then 
                item.Edit = True 
            End If 
        Next 
        RadGrid1.MasterTableView.Rebind() 
    End Sub 
 
 

You may also refer the following forum discussion if you are trying to achieve cell editing in Grid.
Cell Edit

Thanks
Shinu
0
Tony Abou-Akl
Top achievements
Rank 1
answered on 20 Jul 2009, 02:22 PM
Hi Shinu

Thanks for the quick reply but what i'm trying to do is something different
I have a grid that consists of 2 checkboxes Checkbox1 Readonly = false and checkbox2 readonly = true , When loading the grid i loop thru all the item and make them editable. But what i want to is when looping thru the grid, I check if the checkbox1 is checked then i change the Checkbox2 readonly = false so i'm able to select.

Please let me know

Thanks

Tony

0
Daniel
Telerik team
answered on 23 Jul 2009, 12:28 PM
Hello Tony,

Try the following approach and let me know whether it is suitable for your scenario.
<telerik:GridTemplateColumn ...>  
   ...  
    <EditItemTemplate>  
        <input type="checkbox" id="CheckBox1" runat="server"  checked='<%# Eval("Checked") %>'  />  
    </EditItemTemplate>  
</telerik:GridTemplateColumn>  
<telerik:GridTemplateColumn ....>  
    ....  
    <EditItemTemplate>  
        <input type="checkbox" id="CheckBox2" runat="server"  />  
    </EditItemTemplate>  
</telerik:GridTemplateColumn>  

Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) 
    If e.Item.IsInEditMode Then 
        Dim cb2 As HtmlInputCheckBox = TryCast(e.Item.FindControl("CheckBox2"), HtmlInputCheckBox) 
        Dim cb1 As HtmlInputCheckBox = TryCast(e.Item.FindControl("CheckBox1"), HtmlInputCheckBox) 
        cb2.Disabled = Not cb1.Checked 
    End If 
End Sub 

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Tony Abou-Akl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tony Abou-Akl
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or