-增加示例:表格控件->排序->排序(服务器端改变排序列)(PLEaglefly-21456)。

This commit is contained in:
三生石上 2017-12-07 21:12:33 +08:00
parent 4d208e17d5
commit 50e0e55503
7 changed files with 215 additions and 2 deletions

View File

@ -134,6 +134,7 @@
<Content Include="grid\grid_editor_cell_afteredit_rowexpander.aspx" /> <Content Include="grid\grid_editor_cell_afteredit_rowexpander.aspx" />
<Content Include="grid\grid_editor_cell_newdelete_rowexpander.aspx" /> <Content Include="grid\grid_editor_cell_newdelete_rowexpander.aspx" />
<Content Include="grid\grid_rowexpander_grid.aspx" /> <Content Include="grid\grid_rowexpander_grid.aspx" />
<Content Include="grid\grid_sorting_server.aspx" />
<Content Include="grid\grid_sorting_nosortfield.aspx" /> <Content Include="grid\grid_sorting_nosortfield.aspx" />
<Content Include="grid\grid_style_columnclass.aspx" /> <Content Include="grid\grid_style_columnclass.aspx" />
<Content Include="grid\grid_style_rowcolor_lockcolumn.aspx" /> <Content Include="grid\grid_style_rowcolor_lockcolumn.aspx" />
@ -1032,6 +1033,13 @@
<Compile Include="grid\grid_rowexpander_grid_data.ashx.cs"> <Compile Include="grid\grid_rowexpander_grid_data.ashx.cs">
<DependentUpon>grid_rowexpander_grid_data.ashx</DependentUpon> <DependentUpon>grid_rowexpander_grid_data.ashx</DependentUpon>
</Compile> </Compile>
<Compile Include="grid\grid_sorting_server.aspx.cs">
<DependentUpon>grid_sorting_server.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="grid\grid_sorting_server.aspx.designer.cs">
<DependentUpon>grid_sorting_server.aspx</DependentUpon>
</Compile>
<Compile Include="grid\grid_sorting_nosortfield.aspx.cs"> <Compile Include="grid\grid_sorting_nosortfield.aspx.cs">
<DependentUpon>grid_sorting_nosortfield.aspx</DependentUpon> <DependentUpon>grid_sorting_nosortfield.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>

View File

@ -226,6 +226,8 @@
</TreeNode> </TreeNode>
<TreeNode Text="排序(初始不排序)" NavigateUrl="~/grid/grid_sorting_nosortfield.aspx" > <TreeNode Text="排序(初始不排序)" NavigateUrl="~/grid/grid_sorting_nosortfield.aspx" >
</TreeNode> </TreeNode>
<TreeNode Text="排序(服务器端改变排序列)" NavigateUrl="~/grid/grid_sorting_server.aspx" >
</TreeNode>
<TreeNode Text="内存分页" NavigateUrl="~/grid/grid_paging.aspx" > <TreeNode Text="内存分页" NavigateUrl="~/grid/grid_paging.aspx" >
</TreeNode> </TreeNode>
<TreeNode Text="数据库分页" NavigateUrl="~/grid/grid_paging_database.aspx" > <TreeNode Text="数据库分页" NavigateUrl="~/grid/grid_paging_database.aspx" >

View File

@ -0,0 +1,43 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grid_sorting_server.aspx.cs" Inherits="FineUI.Examples.grid.grid_sorting_server" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" runat="server" />
<f:Grid ID="Grid1" Title="表格" EnableCollapse="true" AllowSorting="true" SortField="Gender" SortDirection="ASC"
Width="850px" runat="server" EnableCheckBoxSelect="true" DataKeyNames="Id,Name,AtSchool"
OnSort="Grid1_Sort">
<Columns>
<f:RowNumberField />
<f:BoundField Width="100px" SortField="Name" DataField="Name" DataFormatString="{0}"
HeaderText="姓名" />
<f:TemplateField Width="80px" SortField="Gender" HeaderText="性别">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# GetGender(Eval("Gender")) %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>
<f:BoundField Width="100px" SortField="EntranceYear" DataField="EntranceYear" HeaderText="入学年份" />
<f:CheckBoxField Width="80px" SortField="AtSchool" RenderAsStaticField="true" DataField="AtSchool"
HeaderText="是否在校" />
<f:HyperLinkField HeaderText="所学专业" DataToolTipField="Major" DataTextField="Major"
DataTextFormatString="{0}" DataNavigateUrlFields="Major" DataNavigateUrlFormatString="http://gsa.ustc.edu.cn/search?q={0}"
UrlEncode="true" Target="_blank" ExpandUnusedSpace="True" />
<f:ImageField Width="80px" DataImageUrlField="Group" DataImageUrlFormatString="~/res/images/16/{0}.png"
HeaderText="分组"></f:ImageField>
</Columns>
</f:Grid>
<br />
<f:Button ID="Button1" runat="server" Text="选中了哪些行" OnClick="Button1_Click">
</f:Button>
<f:Button ID="Button2" runat="server" Text="[入学年份]倒序排列" OnClick="Button2_Click">
</f:Button>
<br />
<f:Label ID="labResult" EncodeText="false" runat="server">
</f:Label>
</form>
</body>
</html>

View File

@ -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
}
}

View File

@ -0,0 +1,78 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FineUI.Examples.grid {
public partial class grid_sorting_server {
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// PageManager1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::FineUI.PageManager PageManager1;
/// <summary>
/// Grid1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::FineUI.Grid Grid1;
/// <summary>
/// Label2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label2;
/// <summary>
/// Button1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::FineUI.Button Button1;
/// <summary>
/// Button2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::FineUI.Button Button2;
/// <summary>
/// labResult control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::FineUI.Label labResult;
}
}

View File

@ -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); AddAjaxScript(sb);
} }

View File

@ -29,7 +29,8 @@ FineUI 严格遵守 ExtJS 对开源软件的规定,不再内置 ExtJS 库,
发布历史 发布历史
-增加示例:表格控件->行与列样式->行样式(列锁定)。 -增加示例:表格控件->行与列样式->行样式列锁定vt4u-21458
-增加示例:表格控件->排序->排序服务器端改变排序列PLEaglefly-21456