Hi Nathan,
Thanks for contacting Syncfusion Support.
We have analyzed your query and also we have checked with the IQueryable into the GridVirtualizingCollectionView. It is working fine from our side. For your reference we have attached the test sample on the below location. If you are still facing the issue, we recommend you to convert the IQueryable into the IEnumerable by using the AsEnumerable method or else please revert by modifying the attached sample based on your application to replicate the issue. It will be helpful for us to analyze further.
Sample: http://www.syncfusion.com/downloads/support/forum/121835/ze/DataVirtualization1838171686
Regards,
Sowndaiyan
public ViewModel() { var repository= new EmployeeInfoRespository(); var ch = repository.GetEmployeesDetails(100000); var localViewSource = new GridVirtualizingCollectionView(repository.GetEmployeesDetails(100000).ToList());
//throw new Exception("Take a look at the console output here, and notice how many selects occurred..."); viewSource = localViewSource; |
public class GridVirtualizingCollectionViewExt : GridVirtualizingCollectionView { public IQueryable<Employee> CustomVirtualizingItemsSource { get; set; }
public GridVirtualizingCollectionViewExt() { CustomVirtualizingItemsSource = new EmployeeInfoRespository().GetEmployeesDetails(100000); }
/// <summary> /// Method to return the item at specified index /// </summary> /// <param name="index"></param> /// <returns></returns> public override object GetItemAt(int index) { return CustomVirtualizingItemsSource.ElementAt(index); }
/// <summary> /// Method to return the index of specified item /// </summary> /// <param name="item"></param> /// <returns></returns> protected override int GetIndexOf(object item) { var enumerator = CustomVirtualizingItemsSource.GetEnumerator(); var count = CustomVirtualizingItemsSource.Count(); for (int i = 0; i < count; i++) { if (enumerator.Current == null) enumerator.MoveNext();
if (enumerator.Current.Equals(item)) return i;
if (enumerator.MoveNext()) continue; } return 0; }
/// <summary> /// Method to return the count of records /// </summary> /// <returns></returns> public override int GetViewRecordCount() { return CustomVirtualizingItemsSource.Count(); }
/// <summary> /// Methdo to retunr the source. /// </summary> /// <returns></returns> public override System.Collections.IEnumerable GetInternalSource() { return CustomVirtualizingItemsSource; }
protected override void ProcessSort(System.ComponentModel.SortDescriptionCollection sortDescription) { if (this.SortDescriptions.Count == 0) return; for (int i = 0; i < SortDescriptions.Count; i++) { var sortDecription = SortDescriptions[i]; if (sortDecription.Direction == System.ComponentModel.ListSortDirection.Ascending) CustomVirtualizingItemsSource = CustomVirtualizingItemsSource.OrderBy(sortDecription.PropertyName, GetFunc(sortDecription.PropertyName)).AsQueryable<Employee>(); else CustomVirtualizingItemsSource = CustomVirtualizingItemsSource.OrderByDescending(sortDecription.PropertyName, this.GetFunc(sortDecription.PropertyName)).AsQueryable<Employee>(); } }
public override System.Collections.IEnumerable GetSourceListForFilteringItems() { return CustomVirtualizingItemsSource; }
protected override IEnumerable<GroupResult> GetGroupedSource(string[] groupBy) { IQueryable queryable = CustomVirtualizingItemsSource.OfQueryable().AsQueryable();
var result = CustomVirtualizingItemsSource.GroupByMany(this.SourceType, (property) => this.GetExpressionFunc(property), groupBy);
return result; } |
sfDataGrid.ItemsSource = new GridVirtualizingCollectionViewExt(); |
public class GridVirtualizingCollectionViewExt : GridVirtualizingCollectionView /// <summary> /// Method to apply filter public override void RefreshFilter() { var viewModel = this.dataGrid.DataContext as ViewModel; if (string.IsNullOrEmpty(viewModel.FilterText)) ClearFilter(); else /// <summary> /// Method filtering the data using query /// </summary> /// <param name="columnName"></param> /// <param name="filterText"></param> public void FilterData(string columnName,string filterText) { CustomVirtualizingItemsSource = new EmployeeInfoRespository().GetFilteredSource(columnName,filterText); this.Refresh(); |
// Apply filter to Custom Data Virtualization. dataGrid.View.RefreshFilter(); |