简体   繁体   English

RadGridView的组合框列中的筛选和排序

[英]Filtering and sorting in combobox column of RadGridView

RadGridView is binded to some collection where some properties represent some key values. RadGridView绑定到某些属性表示某些键值的集合。 I've added combobox columns which are binded to these properties and added itemssource which contains key-displayValue pairs. 我添加了绑定到这些属性的组合框列,并添加了包含key-displayValue对的itemssource。

The question is how to setup sorting and filtering by display value? 问题是如何设置按显示值排序和过滤?

You can filter or sort with a CollectionViewSource . 您可以使用CollectionViewSource进行过滤或排序。 CollectionViewSource is a data binding infrastructure to provide the features like filtering and Sorting. CollectionViewSource是一个数据绑定基础结构,提供诸如过滤和排序之类的功能。

How to initialize CollectionView : 如何初始化CollectionView:

ICollectionView _collectionView = CollectionViewSource.GetDefaultView(<<ItemsSource bind to comboBox>>);

Filtering 筛选

To filter a collection view you can define a callback method that determines if the item should be part of the view or not. 要过滤集合视图,您可以定义一个回调方法,该方法确定项目是否应为视图的一部分。 That method should have the following signature: bool Filter(object item) . 该方法应具有以下签名: bool Filter(object item) Now set the delegate of that method to the Filter property of the CollectionView and you're done 现在,将该方法的委托设置为CollectionView的Filter属性,您已完成

Sorting 排序

Sorting data ascending or descending by one or multiple criteria is a common requirement for viewing data. 按一个或多个条件对数据进行升序或降序排序是查看数据的常见要求。 The collection view makes it so easy to achieve this goal. 集合视图使实现此目标变得非常容易。 Just add as many SortDescriptions as you like to the CollectionView 只需将SortDescriptions多的SortDescriptions添加到CollectionView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM