Changing ItemsSource after applying filter not updating GridView Rows

4 posts, 0 answers
  1. Alex
    Alex avatar
    4 posts
    Member since:
    Oct 2015

    Posted 25 Jul Link to this post

    I am changing ItemsSource of RadGridview.

        gv.ItemsSource = enumerated;

         gv.Rebind();

    After that I am clearing all the Descriptors

        gv.FilterDescriptors.Clear();
        gv.SortDescriptors.Clear();
        gv.GroupDescriptors.Clear();

    Then reapplying all Descriptors.

        gv.FilterDescriptors.AddRange(filters);
        gv.SortDescriptors.AddRange(sorts);
        gv.GroupDescriptors.AddRange(groups);

    But the RadGridview is not showing new Items, instead showing items Filtered before.
  2. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 26 Jul Link to this post

    Hello Alex,

    Could you please specify why you need to clear the filter, sort and group descriptors and reapply them afterwards as this does not seem necessary in this situation?

    If you really need to do this, please make sure you're creating a copy of the descriptors, similarly to:

    var filters = new CompositeFilterDescriptorCollection();
    filters.AddRange(gv.FilterDescriptors);
     
    var sorts = new SortDescriptorCollection();
    sorts.AddRange(gv.SortDescriptors);
     
    var groups = new GroupDescriptorCollection();
    groups.AddRange(gv.GroupDescriptors);

    Additionally, I'd like to note that you do not need to call the Rebind method after you change RadGridView's ItemsSource.

    I'm attaching a sample project to demonstrate the approaches I have in mind. Try filtering the Name column and only showing values that start with "man" and then clicking either of the buttons to change the ItemsSource.

    I hope you find this helpful. Do let me know if you need any further assistance on the matter.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alex
    Alex avatar
    4 posts
    Member since:
    Oct 2015

    Posted 27 Jul in reply to Dilyan Traykov Link to this post

    Your solution does not work, not at least using 2011.3.1220.40 dll's.

    I have one filter on a single column.

    After applying filter only one row is displayed.

    Now I change the ItemsSource to some other Collection.

    After that I re apply the filter according to your solution.

    But in the UI one see only the previous row.

    The column on which I have applied the filter shows only one option to select, instead of the whole distinct values in the column.

     

     

  5. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 27 Jul Link to this post

    Hello Alex,

    Here is a video I've captured, demonstrating the behavior I observe at my end. Could you please have a look at it and let me know whether the action steps I've taken are correct or I have done something differently?

    I'm also attaching the sample project from the video as a reference. Please have a look at it as well.

    Thank you in advance for your cooperation on the matter.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top