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

Sorted RadGridView edit issue in MVVM

2 Answers 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alic W
Top achievements
Rank 1
Alic W asked on 24 Oct 2013, 01:33 AM
I have a GridView and use MVVM pattern, I bind SelectedItem to an object in my viewmodel, and on row edit ended pass this as a parameter to my insert method, as described in Telerik documentation here:

http://www.telerik.com/help/wpf/patterns-and-practices-eventtocommand-mvvmlight.html

Namely:

<telerik:RadGridView x:Name="xRadGridView" ItemsSource="{Binding GridItems, Mode=TwoWay}">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="RowEditEnded">
               <i:InvokeCommandAction Command="{Binding TestCommand, Mode=OneWay}"
                              CommandParameter="{Binding ElementName=xRadGridView, Path=SelectedItem}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
</telerik:RadGridView>

Here's the problem - when I first sort the grid by some field and then add a new item, the SelectedItem property on RowEditEnded event is set to an item that was the last item in the list prior to insert. 

For example, I have a field SequenceNumber and sort the grid in descending order. When I insert an item, the field is blank; I then enter a very high value that would place the item to the top of the list; however, the SelectedItem parameter has the value of the last item in the list (which would be the case if no sort was initially performed). Is this a known issue? Please help.

2 Answers, 1 is accepted

Sort by
0
Alic W
Top achievements
Rank 1
answered on 24 Oct 2013, 10:00 PM
I am using RadControls for WPF Q2 2012 SP1 by the way. If it was a known issue that got fixed, were any work-arounds known?
0
Dimitrina
Telerik team
answered on 29 Oct 2013, 04:37 PM
Hi,

The SelectedItem property holds the item you have selected, not the last item that has been inserted. No matter if you sort or not, the SelectedItem should remain the same until you select another item.

Is it not that way in your solution? Would you please share some more information on what would be the expected result for your case?
 

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 >>
Tags
GridView
Asked by
Alic W
Top achievements
Rank 1
Answers by
Alic W
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or