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

[Solved] Read Only Columns

1 Answer 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 03 Apr 2009, 08:02 PM
I have a grid that is bound and already filled with data and it opens with all rows in edit mode.  the first column is GridClientSelectColumn.  I want all records on the row the be read only until the user checks the GridClientSelectColumn then I want only certain cells in the row to be editable.  How can I do this.

Also one other question.
I have a grid that is bound and populated tieh data.  If a user selects a field on the web page I want to change the cells values based on that event.  Is there a way to loop through the grid rows.  Look at the value of the first cell and if it matches the value the user has supplied that I can then alter each cell in that row and change it's value.  

Thanks,
Eric

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Apr 2009, 08:17 AM
Hi Eric,

In order to achieve your purpose, you could handle the ItemCreated or ItemDataBound event of RadGrid. There, if the current item is in edit mode, you can access and set the edit controls as readonly initially.  Then I suggest that you set the ClientSettings.EnablePostBackOnRowClick property to true and handle the ItemCommand event to enable the desired fields when grid row is selected . 
You can review the below articles for more information on how to access grid cell and rows:

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
http://www.telerik.com/help/aspnet-ajax/grdreadonlymodeforindividualcells.html
http://www.telerik.com/help/aspnet-ajax/grddistinguishdifferencesbetweenitemcreateditemdatabound.html

Regarding your second question: Try the below code for looping through all grid rows:

foreach (GridEditableItem item in RadGrid1.Items)  
{  
      

Please check it out and let me know if any issues arise.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or