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

Prevent cell from being edited twice.

2 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 04 Sep 2013, 02:38 PM
I have a grid where the first column is "Region"

When I create a new row I want to ensure that the user can specify the value for "Region" only once. After that I want the cell to be readonly. The region is selected from a control which is specified in the CellEditTemplate. The CellTemplate simply contains a TextBlock

The GridViewDataColumn has the IsReadOnlyBinding property bound to a property on the row object called "RegionIsDefined". I set this to true once the region is selected. Unfortunately this does not make the cell readonly (it still has focus and is in edit mode).

How should I inform the view that I have finished selecting the Region with the CellEditTemplate control?
- should I lose focus on the column?
- is there a cell editing ended event I can call?

<telerik:GridViewDataColumn IsReadOnlyBinding="{Binding RegionIsDefined}">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <myRegionControl>
...
            </myRegionControl>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>


Many thanks


2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 06 Sep 2013, 09:11 AM
Hi,

As I understand you have a cell into edit mode. Then you edit its value and you also update the "RegionIsDefined" property.

This property will take effect and the cell will become ReadOnly after you commit the edit. You should press Enter, click outside of the edited cell or invoke the CommitEdit GridView's command.

How does this work for you?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Charles
Top achievements
Rank 1
answered on 06 Sep 2013, 09:41 AM
Yep it was the grid CommitEdit I was after. I had been looking on the Cell for it. Works perfectly thanks.
Tags
GridView
Asked by
Charles
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Charles
Top achievements
Rank 1
Share this question
or