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

Changing ItemsSource after applying filter not updating GridView Rows

3 Answers 170 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 25 Jul 2016, 01:24 PM

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.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 26 Jul 2016, 11:37 AM
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.
0
Alex
Top achievements
Rank 1
answered on 27 Jul 2016, 05:06 AM

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.

 

 

0
Dilyan Traykov
Telerik team
answered on 27 Jul 2016, 12:03 PM
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.
Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Alex
Top achievements
Rank 1
Share this question
or