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

2 posts, 0 answers
  1. Aryn
    Aryn avatar
    9 posts
    Member since:
    Jul 2014

    Posted 16 Feb Link to this post

    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).

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 19 Feb Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top