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

Update RowDetails while typing in the row cell. Cell ends the editing mode when losing focus.

2 Answers 199 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nargis
Top achievements
Rank 1
Nargis asked on 12 Sep 2014, 07:49 AM
Hello,

I am implementing a WPF-Application that contains a GridView with Rowdetails with RowDetails, where a field is a mandatory input.
Therefore I have two issues to solve:
1. If I typing in the row cell the corresponding field in the row details will not updatet immediately. It is only updated when I press the Enter key. How could I achieve a syncrones update of RowDetails?
2. The mandatory field is filled, I click with the mouse in the RowDetails field (eg textbox). The GridView do not realize that the row cell is no longer edited (I think CellEditEnded event will not fired). How could I achieve the behavior when the cell loses focus, the GridView / RowDetails is updated?

I attached a solution that maps these issues.

Thanks a lot in advance.
Best regards
Nargis

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 15 Sep 2014, 07:06 AM
Hello Nargis,

As to your questions:
1. You can try defining CellEditTemplate for the last column and work with TextBoxBehavior.

For example: 

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
           DataFormatString="{}{0:N0}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBox Text="{Binding Name}" telerik:TextBoxBehavior.UpdateTextOnTextChanged="True" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>


That way every time the user writes something in the cell, the setter of the respective bound property will be called. 

The case is that by default the editing and validation mechanism of RadGridView explicitly updates and validates values when the edit is over. As another solution, you have set UpdateSourceTrigger=PropertyChanged, validation and updating the value would happen on every key stroke.
For example:
<telerik:GridViewDataColumnDataMemberBinding="{Binding Name}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBoxText="{Binding Name, UpdateSourceTrigger=PropertyChanged}"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

2. The row details are part of the row. As the user clicks no them, it is the same as if he clicks on the row itself. That is why the CellEditEnded event will not be raised. Would you please share what do you mean the row details to be updated? Are they not if you define the CellEditTemplate as I suggested above?

Regards,
Dimitrina
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
Nargis
Top achievements
Rank 1
answered on 15 Sep 2014, 04:38 PM
Hello Dimitrina,

thanks a lot! The solution with UpdateTextOnTextChanged solved my problem.

Best regards
Nargis
Tags
GridView
Asked by
Nargis
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Nargis
Top achievements
Rank 1
Share this question
or