World Of ιζσεα.

The Dark Time Will Pass

 

NetTiers学习笔记09---RADGrid + EntityDataSource设置默认排序, 及表格自动排序,分页的方法

前段时间虽然解决了排序和分页的问题,但始终没有解决默认排序的问题,
起初一直把焦点放在EntityDataSource的排序默认值上,但始终搞不定,
今天又花了不少时间Google和研究,终于通过设置RADGrid的默认排序,
把此问题解决了


 1     <rad:RadGrid ID="grid" runat="server" AllowPaging="True" AllowSorting="true" GridLines="None"
 2         EnableAJAX="true" DataSourceID="source" AutoGenerateColumns="False" GroupingEnabled="False">
 3         <ClientSettings>
 4             <Selecting AllowRowSelect="True" />
 5         </ClientSettings>
 6         <MasterTableView DataKeyNames="FId" DataSourceID="source" AllowNaturalSort="False">
 7             <ExpandCollapseColumn Visible="False">
 8                 <HeaderStyle Width="19px" />
 9             </ExpandCollapseColumn>
10             <RowIndicatorColumn Visible="False">
11                 <HeaderStyle Width="20px" />
12             </RowIndicatorColumn>
13             <Columns>
14                 <rad:GridBoundColumn DataField="FNo" HeaderText="发票号" SortExpression="F_No" UniqueName="FNo">
15                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
16                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
17                 </rad:GridBoundColumn>
18                 <rad:GridBoundColumn DataField="FBlno" SortExpression="F_Blno" HeaderText="提(运)单号"
19                     UniqueName="FBlno">
20                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
21                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
22                 </rad:GridBoundColumn>
23                 <rad:GridBoundColumn DataField="AttPayerName" HeaderText="付款单位" AllowSorting="False"
24                     UniqueName="AttPayerName">
25                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
26                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
27                 </rad:GridBoundColumn>
28                 <rad:GridBoundColumn DataField="FVessel" HeaderText="船名/航次/航班/车次" SortExpression="F_Vessel"
29                     UniqueName="FVessel">
30                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
31                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
32                 </rad:GridBoundColumn>
33                 <rad:GridBoundColumn DataField="FDateIssued" DataFormatString="{0:yyyy-MM-dd}" HeaderText="开票日期"
34                     SortExpression="F_DateIssued" UniqueName="FDateIssued">
35                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
36                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
37                 </rad:GridBoundColumn>
38                 <rad:GridBoundColumn DataField="FDateSailed" DataFormatString="{0:yyyy-MM-dd}" HeaderText="开航日期"
39                     SortExpression="F_DateSailed" UniqueName="FDateSailed">
40                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
41                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
42                 </rad:GridBoundColumn>
43                 <rad:GridBoundColumn HeaderText="制单" DataField="AttIssuedName" AllowSorting="False"
44                     UniqueName="AttIssuedName">
45                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
46                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
47                 </rad:GridBoundColumn>
48                 <rad:GridBoundColumn DataField="AttFCheckedName" HeaderText="复核" AllowSorting="False"
49                     UniqueName="AttFCheckedName">
50                     <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
51                     <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
52                 </rad:GridBoundColumn>
53             </Columns>
54             <SortExpressions>
55                 <rad:GridSortExpression FieldName="F_No" SortOrder="Descending" />
56             </SortExpressions>
57         </MasterTableView>
58     </rad:RadGrid>
59     <data:FmInvoicesDataSource ID="source" runat="server" EnablePaging="false" EnableSorting="False"
60         EnableTransaction="False" SelectMethod="GetPaged" EnableDeepLoad="true">
61         <DeepLoadProperties Method="IncludeChildren" Recursive="false">
62             <Types>
63                 <data:FmInvoicesProperty Name="HrmUsers" />
64                 <data:FmInvoicesProperty Name="CrmCustomers" />
65                 <data:FmInvoicesProperty Name="TypeFmInvoiceStatusTypes" />
66             </Types>
67         </DeepLoadProperties>
68         <Parameters>
69             <asp:Parameter Name="WhereClause" />
70             <data:CustomParameter Name="OrderBy" ConvertEmptyStringToNull="true" />
71             <asp:ControlParameter Name="PageIndex" ControlID="grid" PropertyName="CurrentPageIndex"
72                 Type="Int32" />
73             <asp:ControlParameter Name="PageSize" ControlID="grid" PropertyName="PageSize" Type="Int32" />
74             <asp:Parameter Name="RecordCount" Direction="Output" Type="Int32" />
75         </Parameters>
76     </data:FmInvoicesDataSource>



关键部分
   <SortExpressions>
        <rad:GridSortExpression FieldName="F_No" SortOrder="Descending" />
   </SortExpressions>
设定RADGrid的默认排序

   <data:CustomParameter Name="OrderBy" ConvertEmptyStringToNull="true" />
可有可无,但不能在CustomParameter  的DefaultValue或Value 设值,要不然会无法自动排序

posted on 2007-07-25 14:35  Ψιζσεα.  阅读(3360)  评论(9编辑  收藏  举报

导航