找回密码
 立即注册

QQ登录

只需一步,快速开始

Richard.Ma 讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-28 11:30  /   查看:2923  /  回复:0
本帖最后由 Richard.Ma 于 2019-7-8 14:39 编辑

通过良好的数据分析可以做出明智的商业决策。数据过滤是产生这些决策的基本步骤。过滤后分析师就能够构建不同的模型,并从数据中获得决策依据。

Flex Grid和C1 Data Grid提供了强大的功能,可用于过滤和组织数据。对于Component One 2019 v1,我们为WPF和UWP控件也添加了全文过滤功能,使搜索数据更加容易。

过滤和组织数据的工具


全文过滤


全文过滤器功能与Grid中的数据搜索框非常相似。 当您输入文本时,网格将动态更新,并根据您设置的选项突出显示任何完整或部分匹配。


FlexGrid



DataGrid


您可以通过添加FullTextFilterBehavior将全文筛选器添加到FlexGrid:
  1.     <Grid>
  2.         <Grid.RowDefinitions>
  3.             <RowDefinition Height="Auto"/>
  4.         <RowDefinition/>
  5.         </Grid.RowDefinitions>
  6.         <c1:C1TextBoxBase x:Name="filter" Margin="4 4 4 4" Width="200" HorizontalAlignment="Left"/>
  7.         <c1:C1FlexGrid x:Name="grid" Grid.Row="1">
  8.             <c1:C1FlexGridFilterService.FlexGridFilter>
  9.                 <c1:C1FlexGridFilter />
  10.             </c1:C1FlexGridFilterService.FlexGridFilter>
  11.             <c1:C1FlexGridFilterService.FullTextFilterBehavior>
  12.                 <c1:C1FullTextFilter FilterEntry="{Binding Source={x:Reference filter}}" />
  13.             </c1:C1FlexGridFilterService.FullTextFilterBehavior>
  14.         </c1:C1FlexGrid>
  15.     </Grid>
复制代码



这个全文过滤可以与FlexGrid中的列级过滤相结合


向C1DataGrid添加过滤器是类似的, 但是您需要在文本框上触发Text Changed事件以触发过滤器:
  1.     <Grid>
  2.         <Grid.RowDefinitions>
  3.             <RowDefinition Height="Auto" />
  4.             <RowDefinition />
  5.         </Grid.RowDefinitions>
  6.         <c1:C1TextBoxBase x:Name="filter" Margin="0 0 0 10"
  7.                                        Width="200"
  8.                                        HorizontalAlignment="Left"
  9.                                        VerticalAlignment="Center" TextChanged="filter_TextChanged"/>
  10.         <c1:C1DataGrid x:Name="grid" Grid.Row="1"
  11.                             AutoGeneratingColumn="grid_AutoGeneratingColumn"
  12.                             CanUserAddRows="False"
  13.                             RowHeight="30"
  14.                             IsReadOnly="true">
  15.             <c1:C1FullTextSearchBehavior.FullTextSearchBehavior>
  16.                 <c1:C1FullTextSearchBehavior />
  17.             </c1:C1FullTextSearchBehavior.FullTextSearchBehavior>
  18.         </c1:C1DataGrid>
  19.     </Grid>
复制代码



在后台的代码中,您需要按以下方式添加过滤器Text Changed事件:

  1. private void filter_TextChanged(object sender, TextChangedEventArgs e)
  2. {
  3.         C1FullTextSearchBehavior.GetFullTextSearchBehavior(grid).Filter = filter.Text;
  4. }
复制代码



与FlexGrid中的全文过滤不同,在C1DataGrid中这个过滤器不能与C1Data Grid中的其他过滤组合。

另外,以下几种不同的选项可用于确定过滤器的行为方式:

MatchCase: 过滤区分大小写。
MatchWholeWord: 仅匹配整个单词。
MatchNumbers: 此选项强制数字匹配,可用于在数字和日期时间列上禁用/启用过滤器。 默认值是true。
TreatSpacesAsAndOperator: 用多个关键词进行过滤,其中空格被视为And运算符。默认值为false





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部