Column Filtering of the grid does not seem to work when using a VirtualCollection as the ItemSource of the grid. When I was using Infragistics 10.1 version, I found that the documentation mentioned that it doesn't work (based on this thread - http://community.infragistics.com/forums/p/41910/233682.aspx). So, I implemented the suggested workaround - to capture the Filtering event of the grid and do the update on my own. After setting up the proper filters, I called VirtualCollection.Refresh() method to reload the filtered data. I call this within the VirtualCollection.DeferRefresh() block.
However, the same code does not work in 10.2 version. It throws a "Cannot perform Refresh when editing or adding a new item" error. I searched for this error in the documentation and could not find any reference to it. In the documentation, it says that in the latest version, the filter conditions will be added to the Virtual Collection's FilterCondition Property and the same code shows how to implement the ItemDataRequested event handler. This does not seem to be the case. The ItemDataRequested is not automatically called when filtering.
Please help.
- Anand
I'm having a similar problem in my code. I set the AnticipatedCount to the number of totals count inside the DataRequested method which fires the DataRequested event again. This leads to the DataRequested method firing multiple times. I'm using the 11.2.20112.74 version of the VirtualCollection assembly. You mentioned there would be a fix to the issue? Should it be in this version already or not? Is there even a fix for the issue. I tried using a Thread.Sleep where you suggested but I couldn't get it working. If I remove the AnticipatedCount setting, everything works fine but the grid items count doesn't update as already mentioned.
I'm planning to upgrade to newer Infragistics version at some point and would like to know if something has been done about this or should I try to fix it myself?
Hi,
Sorry for the delayed reply.
Are you talking about the case when clearing the filter is done after filtering where all rows get filtered out and the grid becomes empty? I am able to reproduce that, however in clearing filtering in other cases is working as expected.
BTW, removing a filter the causes XamGrid to fire the Filtered event.
Thanks,
I want to do Filtering using Virtual Collection. As you said earlier currently XamGrid is not supporting Virtual Collection Filtering. And you gave a alternate way by using Filtered Event. But i have one doubt as I know When I clear a filter from Grid Column it will not fire a Filtered Event. In that case how to handle the data. While adding new filters it will fire Grid_Filtered event but while removing it wont fire Filtered event. So Whats the solution for this.
Thank You
Great to hear that you have achieved your scenario.
Regarding the issue when AnticipatedCount = 0, I ran into that too, and will create a bug item to get a fix from the developer in the future SR.
Thanks for using our components and for participating in analyzing those issue.
Regards,
Awesome!! It is working now. Thanks a lot.
I did find a minor issue - If we assign Anticipated count to data.Count and data.Count = 0 (because there are no records matching the filter criteria), then the grid does not refresh with new data even if we remove the filter setting or change the filter to some other value that matches some records. I guess this is because the AnticipatedCount is set to 0 and so the next time ItemDataRequested is not even called because the VirtualCollection anticipates the result set will have 0 records. I modified the Filtered event as follows
private void XamGrid_Filtered(object sender, Infragistics.Controls.Grids.FilteredEventArgs e){ var grid = (XamGrid)sender; using (this._collection.DeferRefresh()) { this._collection.FilterConditions.Clear(); foreach (var r in grid.FilteringSettings.RowFiltersCollection) { this._collection.FilterConditions.Add(r); } if (this._collection.AnticipatedCount == 0) this._collection.AnticipatedCount = grid.PagerSettings.PageSize; }}