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

Cells enable/disable

1 Answer 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vinicius Maeda
Top achievements
Rank 1
Vinicius Maeda asked on 20 Apr 2011, 08:17 PM
Hi,
I've seen the example enable/disable and it wasn´t possible to solve my problem. I had problems specially in the following code:

 GridViewRow row = RadGridView1.ItemContainerGenerator.ContainerFromItem(RadGridView1.Items[0]) as GridViewRow;

It always returns nothing.

My problem is:
There are 2 cases.
1) I need to disable some gridview cells at the moment of the load event of the grid. The variables I'm creating to select the specific cell I want aren't working because I only get the specific cell on editingcells or validatingcells methods.
 
2) I need to disable some gridview cells when I select an option on gridviewcomboboxcolumn. In this case, I would like to know how to create a selectionchange event for the gridviewcomboboxcolumn. I've read other topic of this forum, but It wasn't enough.

In both cases, the situation become more complex because the grid is dinamically generated, depending on database consults. So, I can't use the xaml code to solve my problem. 

I hope you can help. I can describe these cases in more details if it's necessary.
Thank you very much.
 

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 22 Apr 2011, 01:14 PM
Hi Vinicius Maeda,

Please find my answers below:
1. Generally, a GridViewRow will be null in case it is not yet created. For example, if you are trying to get the corresponding row of an item that is not in the visual port, the value will probably be null, depending on the exact implementation. So, in order to provide you with a more appropriate solution, I would need a bit more details - when are you try to get a particular row - do you handle any event ? What is the exact scenario that you want to accomplish by getting the row ? 
2. It is not recommended to work with the visual elements - like GridViewCell for example as they will be created when firstly needed and recycled and reused afterwards. My suggestion would be to work with the underlaying data item instead. In case you want to disable a particular cell, you may use the IsReadOnlyBinding instead. Please take a look at this article for further reference.
3. You may take a look at this blog post (point 3) illustrating how you may define a SelectionChanged event for handling the GridViewComboBoxColumn. Still, if you want to make some cells depending on the value selected in the RadComboBox, you would better do this in the setter of the required property. You may take a look at the sample project attached for a reference.

Best wishes,
Maya
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
Tags
GridView
Asked by
Vinicius Maeda
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or