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

Make single cell readonly

18 Answers 909 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kristof
Top achievements
Rank 1
Kristof asked on 22 May 2007, 01:09 PM
Hi,

the MS DataGridView supports readonly on cell-level. I haven't found the same property on the RadGridView. Is it possible?

Ben

18 Answers, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 22 May 2007, 04:33 PM
Hello Kristof,

Currently RadGridView does not support readonly mode on the cell level. You can make an entire column readonly by using its ReadOnly property.

Could you tell us more about the specific scenario you're facing? Do you need a particular cells in a row to be readonly subject to a condition applied to a value in another column of the row?

 
Best wishes,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kristof
Top achievements
Rank 1
answered on 23 May 2007, 07:12 AM
Hey Kiril,

the grid I'm displaying contains data aranged in columns. All columns are readonly, except for one: the value column. Here a user can change the value to his likings. But, it could be that the user doesn't have sufficient rights to change the value in row one, but he does for row two.

So, some cells in one column could be readonly while others are read/write.

As said before, the MS DataGridView does support this feature, maybe a good feature for the RadGridView also.
0
Dimitar Kapitanov
Telerik team
answered on 24 May 2007, 02:08 PM
Hi Kristof,
We have this feature on our ToDo list and will implement it ASAP.
Thank you for the valuable suggestion.

Kind regards,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Princy
Top achievements
Rank 1
answered on 16 Oct 2007, 03:39 AM
Hi Kristof,

Here is a forum link that discusses a similar issue. Check it out and let me know whether it helps.

http://www.telerik.com/community/forums/thread/b311D-hdeta.aspx

Princy.
0
Phil
Top achievements
Rank 1
answered on 15 Mar 2009, 05:02 AM
This is approaching two years, was this ever implemented?

Thanks
0
Jack
Telerik team
answered on 16 Mar 2009, 01:30 PM
Hi Phil,

Thank you for the question.

You can make some cell read only when processing the CellBeginEdit event:

void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
    if ((int)this.radGridView1.CurrentRow.Cells[2].Value < 10) 
    { 
        e.Cancel = true
    } 

I hope this helps. Should you have any questions, don't hesitate to contact us.

Best wishes,
Jack
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.
0
Matt
Top achievements
Rank 1
answered on 23 Mar 2010, 12:13 PM
I see this question was posted back in 2007.  Does the grdiview allow row-level read-only settings yet?
0
Jack
Telerik team
answered on 24 Mar 2010, 02:14 PM
Hello Matt,

We decided that the current RadGridView API is enough to control the read only state of grid cells. Just like shown in my previous post you can handle the CellBeginEdit method to make a cell read-only. Nevertheless, if more people request the same feature we will reconsider our decision.

Should you have any other questions, please contact me.

Best wishes,
Jack
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.
0
Matt
Top achievements
Rank 1
answered on 24 Mar 2010, 02:39 PM
Since it was first asked for in 2007 I won't hold out a great deal of hope.
0
Jack
Telerik team
answered on 24 Mar 2010, 03:19 PM
Hello Matt,

Did the CellBeginEdit event help in solving the issue? If not, please describe it in detail and I will try to find a proper solution.
 

Best wishes,
Jack
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.
0
Matt
Top achievements
Rank 1
answered on 24 Mar 2010, 03:24 PM
I wish to make the row(s) read-only at the point of creating the row and not cater for it at the point of the user clicking on it.
0
Jack
Telerik team
answered on 25 Mar 2010, 10:26 AM
Hello Matt,

I understand. Currently, there is no event that you can handle to initialize newly created rows. However, you can iterate all rows and set the Tag property. Later, you can use this property to indicate whether the row is read only or not. Please, describe in details the exact behavior that you want to achieve and I will try to find the best option for you.

 

All the best,
Jack
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.
0
lucerias
Top achievements
Rank 1
answered on 09 Nov 2011, 12:22 PM

I want to make a single cell readonly = false so that it can be edited.
What i want to achieve is something like this. I have three columns, first is CustomerID, second is CustomerAddress, last is Checkbox.

All columns are in readonly.
Whatever user tick on the checkbox, customeraddress must be editable.

I have got the row already but not able to set CustomerAddress to be editable.

My xaml code is shown as below. SilverLight version is 4.

<telerik:GridViewDataColumn Header="Customer address" DataMemberBinding="{Binding CustomerAddress, Mode=TwoWay}" IsReadOnly="True" >
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding CustomerAddress}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
  
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBox Text="{Binding CustomerAddress, Mode=TwoWay}"  />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

My behind code is shown as below.

CheckBox chk = (CheckBox)sender; 
GridViewRow row = chk.ParentOfType<GridViewRow>();
  
row.Cells[1].IsReadOnly = False not supported.

I stuck at this for few days already. I have achieved using TextBox instead of TextBlock but the look and feel just not right.
Hence i want it to be displayed in TextBlock and edit in TextBox.

Please let me know the alternative. Thank you very much.
0
Dimitrina
Telerik team
answered on 10 Nov 2011, 05:31 PM
Hello Lucerias,

 You may use the IsReadOnlyBinding instead of IsReadOnly. For further reference please take a look at this article

I hope that this is what you need.

Regards,
Didie
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Tim
Top achievements
Rank 1
answered on 23 Jul 2014, 07:27 PM
Hello,
     In our project we need a particular cells in a row to be readonly subject to a condition applied to a value in another column of the row?     Is this possible to do yet?

Best Regards,
Tim
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jul 2014, 01:09 PM
Hello Tim,

Thank you for writing.

The CellBeginEdit event fires when the cell is about to enter edit mode. You can cancel edit mode (simulate read-only behavior) at this stage by setting the Cancel property to true:
private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (e.Column.Name == "UnitPrice" || e.Column.Name == "ProductName")
    {
        rowView = e.Row.DataBoundItem as DataRowView;
        if (rowView != null)
        {
            if (int.TryParse(rowView.Row["SupplierID"] + "", out id))
            {
                if (id == 4)
                {
                    e.Cancel = true;
                }
            }
        }
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Venkatesh
Top achievements
Rank 1
answered on 14 Aug 2014, 12:07 PM
Hi,

I want to make read only for the rad grid cells based on a condition.
 
Eg:  1      2     3      N/A    5        6      7     N/A
        23   34   56    12      N/A    12     10   33

The cells which is having N/A i need to make read only.

I am using radgrid batch edit with GridTemplateColumn. Label in ItemTemplate, RadNumericTextBox  in EditItemTemplate.


Regards,
Venkatesh.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Aug 2014, 06:30 AM
Hello Venkatesh,

Thank you for writing.

I am not sure whether your question is related to RadGridView from the Telerik UI for WinForms suite. However, you can also use the CellBeginEdit event and cancel it if the current cell's value or text is "N/A".

Another approach to simulate read-only behavior is to use the CellFormatting event and set the CellElement.Enabled property to false and the UseDefaultDisabledPaint property to false as well. Thus, the user will not be allowed to edit the specific cell:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.Text != null && e.CellElement.Text == "N/A")
    {
        e.CellElement.Enabled = false;
        e.CellElement.UseDefaultDisabledPaint = false;
    }
    else
    {
        e.CellElement.Enabled = true;
        e.CellElement.UseDefaultDisabledPaint = true;
    }
}

If your question is related to RadGrid from the Telerik UI for ASP.NET AJAX suite, feel free to post your question in the appropriate forum.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Kristof
Top achievements
Rank 1
Answers by
Kiril
Telerik team
Kristof
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
Princy
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Jack
Telerik team
Matt
Top achievements
Rank 1
lucerias
Top achievements
Rank 1
Dimitrina
Telerik team
Tim
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Venkatesh
Top achievements
Rank 1
Share this question
or