C1DataGrid的排序和过滤

1.在XAML前加入

xmlns:local="clr-namespace:DEMO.Web" 
xmlns:ria="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"

2.由于C1DataGrid不能将从RIA中直接取出的数据进行过滤,因此需要加入C1RiaAdapter控件。

        <c1:C1RiaAdapter x:Name="_adapter" DataGrid="{Binding ElementName=c1DataGrid1}" InteractionMode="Prompt">
            <ria:DomainDataSource x:Name="_myDataSource" QueryName="GetT_EMPLOYEEQuery" >
                <ria:DomainDataSource.DomainContext>
                    <local:DSZDBDomainContext/>
                </ria:DomainDataSource.DomainContext>
                <ria:DomainDataSource.SortDescriptors>
                    <ria:SortDescriptor PropertyPath="EMPLOYEE_ID" Direction="Ascending" />
                </ria:DomainDataSource.SortDescriptors>
                <ria:DomainDataSource.FilterDescriptors>
                    <ria:FilterDescriptor PropertyPath="EMPLOYEE_NAME" Operator="StartsWith" Value="" />
                    <ria:FilterDescriptor PropertyPath="EMPLOYEE_SEX" Operator="Contains" Value="" />
                </ria:DomainDataSource.FilterDescriptors>
            </ria:DomainDataSource>
        </c1:C1RiaAdapter>

其中DataGrid="{Binding ElementName=c1DataGrid1}" 为c1DataGrid的名字。
      QueryName="GetT_EMPLOYEEQuery" 为DomainDataSource的查询方法。

3.C1DataGrid控件的代码:

        <c1:C1DataGrid ItemsSource="{Binding Data, ElementName=_adapter}" AutoGenerateColumns="False" Height="140"x:Name="c1DataGrid1" VerticalAlignment="Top" Width="474" ColumnHeaderClickAction="Sort"CanUserFilter="True">
            <c1:C1DataGrid.Columns>
                <c1:DataGridTextColumn Binding="{Binding EMPLOYEE_ID}" SortMemberPath="EMPLOYEE_ID" CanUserResize="False" CanUserSort="True" Header="编号" Width="50" />
                <c1:DataGridTextColumn Binding="{Binding EMPLOYEE_NAME}" SortMemberPath="EMPLOYEE_NAME"  CanUserResize="True" CanUserSort="True" Header="姓名" Width="150"FilterMemberPath="EMPLOYEE_NAME"/>
                <c1:DataGridTextColumn Binding="{Binding EMPLOYEE_SEX}"  SortMemberPath="EMPLOYEE_SEX" CanUserResize="True" CanUserSort="True" Header="性别" Width="40"FilterMemberPath="EMPLOYEE_SEX"/>
            </c1:C1DataGrid.Columns>
        </c1:C1DataGrid>

 

  

 

 

posted @ 2012-09-04 23:18  ajeeky  阅读(797)  评论(0编辑  收藏  举报