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

readonly cells

3 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robbie
Top achievements
Rank 1
Robbie asked on 21 Jul 2008, 10:05 AM
Hi There,
I want to mark cells as readonly based on a given value in the databounditem and in some situations i want to mark the complete row as being readonly.

Is this possible?

many tanx in advance, grtz

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 24 Jul 2008, 11:51 AM
Hi Robbie,

Currently, we have ReadOnly property for the RadGridView control, but not for separate rows or cells. However, you can achieve the desired behavior by canceling the CellBeginEdit event on a specific condition:
private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)  
{  
    // read-only just for the cell  
    if(this.radGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Sales Manager")  
    {  
        e.Cancel = true;  
    }  
 
    // read-only for the whole row which has a specific value in a specific cell  
    if (this.radGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() == "Sales Representative")  
    {  
        e.Cancel = true;  
    }  
 
    // read-only depending on the column and row indexes  
    if ((e.ColumnIndex == 3) && (e.RowIndex == 2))  
    {  
        e.Cancel = true;  
    }  
 
    if (e.RowIndex == 0)  
    {  
        e.Cancel = true;  
    }  

If you have additional questions, feel free to contact me.

Sincerely yours,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Robbie
Top achievements
Rank 1
answered on 25 Jul 2008, 08:31 PM
Tanx Nikolay !
I think this will work nicely and if you can tell me how to prevent the pencil from appearing when clicking on a cell that has a canceled beginedit event you will really make my day!!

Looking forward to your reply,
Robbie
0
Nikolay
Telerik team
answered on 28 Jul 2008, 12:54 PM
Hi Robbie,

Thank you for raising this question.

I apologize for any inconvenience this problem has caused you. I have reproduced your problem and it has been logged as a bug. The issue will be addressed in one of our next versions. I cannot provide you with a workaround for the time being.

Your Telerik points account was updated for pointing out the issue.

If you have any other questions, please don't hesitate to contact us.

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Robbie
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Robbie
Top achievements
Rank 1
Share this question
or