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

Telerik RadGridView Binding is null after Applying Filter and selecting an item

1 Answer 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aryn
Top achievements
Rank 1
Aryn asked on 16 Feb 2016, 06:33 PM

Hello,

 I have built a radgridview and binded to selectedItems. This works great and as I imagined until I filter the grid (using the default telerik filtering) on a column and then selecting a new item which selectedItems is null. Can someone please help me understand what is difference for selecteditems with the entire collection and a filtered collection? And why the binding is null after being filtered? Thank you. 

 Below is my binding.

<telerik:RadGridView x:Name="radGridView" GroupRenderMode="Flat"
Width="Auto"
Height="Auto"
MaxHeight="500"
CanUserFreezeColumns="True"
RowIndicatorVisibility="Collapsed"
AutoGenerateColumns="False"
Grid.Row="0"
ShowGroupPanel="False"
ItemsSource="{Binding GridModels}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
RowEditEnded="RadGridView_RowEditEnded">

 

Once again, this works great until I filter and then try selecting a new row (I am not selecting and then filtering).

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 19 Feb 2016, 08:07 AM
Hello Aryn,

When you apply a filter descriptor, all entries that don't pass the criteria will be hidden from the UI. In such cases, if the selected item is among those entries, the SelectedItem property will be cleared (set to null). This is an implementation detail of the control - it doesn't make much sense to leave the item in the selection as it's a primarily UI functionality. That's the behavior I'm observing locally and I couldn't replicate a setup in which the binding itself is set to null.

Is this behavior preventing the proper logic of your application? If that's the case, please elaborate a bit on what you're trying to achieve and I'll gladly help with an alternative solution.

As to the difference between SelectedItem and SelectedItems - those relate to the different types of selection modes in the control. You can take a look at the Selection article for additional details on the specifics.

I hope this helps.

Regards,
Petya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Aryn
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or