RowDetails editing, MVVM, and more

2 posts, 0 answers
  1. Randy Hompesch
    Randy Hompesch avatar
    148 posts
    Member since:
    Nov 2008

    Posted 30 Nov 2016 Link to this post

    I have an eventtocommandbehavior  binding as shown below to deal with the EditEnded event of the raddataform which I am using as a row details editor in my gridview. I get the call in my viewmodel from the command with the args, but they are kinda useless.
    How to tell what row was being edited?
    Also, if the user hits the cancel button how do I prevent the gridview from being updated? I am beginning to wonder what the raddataform buys me. 
    My current dataform uses ONLY custom fields. Couldn't I just get rid of the raddataform and use a regular grid with the controls I want as a rowdetailstemplate? If I did that, how could I wire up the OnRowEditEnded event of the gridview to a command associated with a button in my rowdetails editor? For that matter, how to wire it up to the raddataform if I have to use it.
    I hope I'm making sense here.

    Any help would be great.

    Thanks ... Ed





    <telerik:RadDataForm CurrentItem="{Binding}" CommandButtonsVisibility="All">
            <telerik:EventBinding Command="{Binding DataContext.EditEndedCommand, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}" EventName="EditEnded" PassEventArgsToCommand="True"/>
  2. Stefan Nenchev
    Stefan Nenchev avatar
    665 posts

    Posted 05 Dec 2016 Link to this post

    Hello Randy,

    I am not sure of your exact setup and the details of the functionalities you aim at, however, pressing the "Cancel" button will automatically revert the changes you have applied through the DataForm. As for getting the details of the item that was edited, you can pass it as a CommandParamater for your custom command:

            <telerik:EventBinding Command="{Binding CustomCommand,Source={StaticResource MyViewModel}}"
                                        CommandParameter="{Binding Item, RelativeSource={RelativeSource FindAncestor, AncestorType=telerik:GridViewRow}}"/></telerik:EventToCommandBehavior.EventBindings>

    You are free to set up a DataTemplate of your choice for the RowDetails of the RadGridView. With this in mind, it is possible to add another grid or whatever element you need.  However, the RowEditEnded event of the RadGridView will be fired only when editing the specific row through the UI.  You can consider using an ObservableItemCollection which raises notifications when one of its items property is changed(ItemChanged event).

    Have a great week.

    Stefan Nenchev
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top