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

RowDetails editing, MVVM, and more

1 Answer 376 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 30 Nov 2016, 12:39 PM

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:EventToCommandBehavior.EventBindings>
 
        <telerik:EventBinding Command="{Binding DataContext.EditEndedCommand, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}}" EventName="EditEnded" PassEventArgsToCommand="True"/>
 
    </telerik:EventToCommandBehavior.EventBindings>
 
</telerik:RadDataForm>

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 05 Dec 2016, 08:01 AM
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:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding Command="{Binding CustomCommand,Source={StaticResource MyViewModel}}"
                                    EventName="EditEnded"
                                    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.

Regards,
Stefan Nenchev
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or