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

3 posts, 0 answers
  1. Nargis
    Nargis avatar
    8 posts
    Member since:
    Aug 2014

    Posted 12 Sep 2014 Link to this post

    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. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Sep 2014 Link to this post

    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.
     
  3. Nargis
    Nargis avatar
    8 posts
    Member since:
    Aug 2014

    Posted 15 Sep 2014 in reply to Dimitrina Link to this post

    Hello Dimitrina,

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

    Best regards
    Nargis
Back to Top