diff --git a/FineUI_v6/FineUI.Examples/FineUI.Examples.csproj b/FineUI_v6/FineUI.Examples/FineUI.Examples.csproj index 1ae3fd6..5c510c2 100644 --- a/FineUI_v6/FineUI.Examples/FineUI.Examples.csproj +++ b/FineUI_v6/FineUI.Examples/FineUI.Examples.csproj @@ -134,6 +134,7 @@ + @@ -1032,6 +1033,13 @@ grid_rowexpander_grid_data.ashx + + grid_sorting_server.aspx + ASPXCodeBehind + + + grid_sorting_server.aspx + grid_sorting_nosortfield.aspx ASPXCodeBehind diff --git a/FineUI_v6/FineUI.Examples/common/menu.xml b/FineUI_v6/FineUI.Examples/common/menu.xml index 2562313..fbcacea 100644 --- a/FineUI_v6/FineUI.Examples/common/menu.xml +++ b/FineUI_v6/FineUI.Examples/common/menu.xml @@ -226,6 +226,8 @@ + + diff --git a/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx new file mode 100644 index 0000000..6c09f84 --- /dev/null +++ b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx @@ -0,0 +1,43 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grid_sorting_server.aspx.cs" Inherits="FineUI.Examples.grid.grid_sorting_server" %> + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + diff --git a/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.cs b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.cs new file mode 100644 index 0000000..420e46a --- /dev/null +++ b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Data; +using System.Text; + +namespace FineUI.Examples.grid +{ + public partial class grid_sorting_server : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + BindGrid(); + } + } + + #region BindGrid + + private void BindGrid() + { + string sortField = Grid1.SortField; + string sortDirection = Grid1.SortDirection; + + DataTable table = DataSourceUtil.GetDataTable(); + + DataView view1 = table.DefaultView; + view1.Sort = String.Format("{0} {1}", sortField, sortDirection); + + Grid1.DataSource = view1; + Grid1.DataBind(); + } + + #endregion + + #region Events + + protected void Button1_Click(object sender, EventArgs e) + { + labResult.Text = HowManyRowsAreSelected(Grid1); + } + + protected void Grid1_Sort(object sender, GridSortEventArgs e) + { + //Grid1.SortDirection = e.SortDirection; + //Grid1.SortField = e.SortField; + + BindGrid(); + } + + + protected void Button2_Click(object sender, EventArgs e) + { + Grid1.SortDirection = "DESC"; + Grid1.SortField = "EntranceYear"; + + BindGrid(); + } + + #endregion + + } +} diff --git a/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.designer.cs b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.designer.cs new file mode 100644 index 0000000..53266b7 --- /dev/null +++ b/FineUI_v6/FineUI.Examples/grid/grid_sorting_server.aspx.designer.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FineUI.Examples.grid { + + + public partial class grid_sorting_server { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::FineUI.PageManager PageManager1; + + /// + /// Grid1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::FineUI.Grid Grid1; + + /// + /// Label2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label2; + + /// + /// Button1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::FineUI.Button Button1; + + /// + /// Button2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::FineUI.Button Button2; + + /// + /// labResult control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::FineUI.Label labResult; + } +} diff --git a/FineUI_v6/FineUI/WebControls/PanelBase.Grid/Grid.cs b/FineUI_v6/FineUI/WebControls/PanelBase.Grid/Grid.cs index bbc4a2f..d95baaa 100644 --- a/FineUI_v6/FineUI/WebControls/PanelBase.Grid/Grid.cs +++ b/FineUI_v6/FineUI/WebControls/PanelBase.Grid/Grid.cs @@ -2147,7 +2147,7 @@ namespace FineUI //return jo; - + JArray ja = new JArray(); foreach (GridRow row in Rows) @@ -2812,6 +2812,21 @@ namespace FineUI //} + // 排序在服务器端发生变化 + // 或者:数据重新加载了,此时也需要重新设置排序列 + if (AllowSorting) + { + if (dataReloaded || PropertyModified("SortField") || PropertyModified("SortDirection")) + { + var sortFieldColumnId = GetSortColummID(); + if (!String.IsNullOrEmpty(sortFieldColumnId)) + { + sb.AppendFormat("{0}.f_setSortIcon('{1}','{2}');", XID, sortFieldColumnId, SortDirection); + } + } + } + + AddAjaxScript(sb); } diff --git a/FineUI_v6/FineUI/release_history.txt b/FineUI_v6/FineUI/release_history.txt index ccdffd4..0e247a1 100644 --- a/FineUI_v6/FineUI/release_history.txt +++ b/FineUI_v6/FineUI/release_history.txt @@ -29,7 +29,8 @@ FineUI 严格遵守 ExtJS 对开源软件的规定,不再内置 ExtJS 库, 发布历史 - -增加示例:表格控件->行与列样式->行样式(列锁定)。 + -增加示例:表格控件->行与列样式->行样式(列锁定)(vt4u-21458)。 + -增加示例:表格控件->排序->排序(服务器端改变排序列)(PLEaglefly-21456)。