Hi Soumyajit,
Thank you for using Syncfusion products.
We have analysed your query and currently we don’t have direct support to apply the filters in view model collectionview. You can bind the collectionview to the grid and filter the grid using Filter predicate in sfdatagrid. We have prepared the sample for Binding CollectionView with SfDataGrid and set the ItemSource as CollectionView to Grid. Then the Sorting, Filtering, Grouping operations are performed through “SfDataGrid.View”. Please find the sample from following location:
Sample: http://www.syncfusion.com/downloads/support/forum/119487/ze/SfDataGridSample17393417
Please let us know if you have any queries.
Thanks,
Elavarasan M
GridQueryableCollectionViewWrapper and set it as the itemssource of SfDataGrid. Please find the below code snippet:
Code Snippet:
//itemssource for grid as CustomizedQueryablecollectionviewrapper private CustomQueryableCollectionViewWrapper collectionView; public CustomQueryableCollectionViewWrapper CollectionView { get { return collectionView; } set { collectionView = value; RaisePropertyChanged("CollectionView"); } }
//CollectionView is the type of customized GridQueryablecollectionViewWrapper which is the itemssource of sfdatagrid. (this.datagrid.DataContext as ViewModel).CollectionView = new CustomQueryableCollectionViewWrapper(emp as IEnumerable, ViewModel.SfGridValue); |
Please refer the below code snippet to define the SfDataGrid in xaml.
Code Snippet:
<Syncfusion:SfDataGrid x:Name="datagrid" AllowFiltering="True" AutoGenerateColumns="False" ColumnSizer="SizeToHeader" FrozenRowsCount="4" ItemsSource="{Binding CollectionView}" local:ViewModel.DataGrid="{Binding ElementName=datagrid}"> |
Please refer the following code snippet to override GridQueryableCollectionViewWrapper.
Code Snippet:
//customized GridQueryablecollectionViewWrapper public class CustomQueryableCollectionViewWrapper : GridQueryableCollectionViewWrapper { public CustomQueryableCollectionViewWrapper(IEnumerable source, SfDataGrid grid) : base(source, grid) {
}
public override bool FilterRecord(object record) { var item = record as BusinessObjects; if (item.EmployeeID >10) return true; return false; } |
Hi Soumyajit,
Thank you for the update.
Please let us know if you need further assistance on this.
Thank you,
Jai Ganesh S
Hi Soumyajit,
As we already mentioned in our first update, currently we don’t have a direct support to apply the filters in view model collectionview. Hence we have provided the solution to filter a grid using view filter and also provided a solution for overriding GridQueryableCollectionViewWrapper and apply the filter but in your last update you have pass the CollectionViewAdv to your model and apply the filter. Could you please share the details for how you pass the CollectionViewAdv to your model or please share the sample for this? This would be more helpful for us.
Please let us know if you have any query.
Regards,
Jai Ganesh S
Hi Soumyajit,Could you please tell me how you managed to pass the CollectionViewAdv to your model?Synchfusion's solution is not usable and absolutely not MVVM friendly.Thanks!