AspxGridView 联系客服

发布时间 : 星期五 文章AspxGridView更新完毕开始阅读f6b659f86edb6f1afe001f6b

十一、 客户端数据搜索 1.数据过滤

(1)调用AutoFilterByColumn()方法实现过滤。 语法1:void AutoFilterByColumn(ASPxClientGridViewColumn column, string val);

语法2:void AutoFilterByColumn(int columnIndex, string val); 语法3:void AutoFilterByColumn(string columnFieldNameOrId, string val); 不会自动清除之前的过滤条件。 (2)调用ApplyFilter实现过滤。

语法:function ApplyFilter(filterExpression : String); 语法:

var filterExpr =

document.getElementById(\grid.ApplyFilter(filterExpr); 会自动清除之前的过滤条件。

(3)调用ClearFilter清除过滤条件 语法:function ClearFilter(); 十二、 服务端数据搜索 1.数据过滤

(1)调用AutoFilterByColumn()方法可以实现服务端数据过滤。

AutoFilterByColumn语法:void AutoFilterByColumn(GridViewColumn column,string value) 参数说明:

column:要过滤的栏位

value:要过滤的栏位值。可以使用通配符。 例:数据过滤

protected void btnServerFilter_Click(object sender, EventArgs e) {

string filterColumnName =

this.ddlFilterColumNames.SelectedValue; if (filterColumnName != null) {

GridViewColumn col =

this.ASPxGridView1.Columns[filterColumnName] as GridViewColumn; this.ASPxGridView1.AutoFilterByColumn(col, this.txtFilterColumnValue.Text); } }

(2)通过设置过滤工具条让用户自行输入条件过滤数据 this.ASPxGridView1.Settings.ShowFilterBar = GridViewStatusBarMode.Visible;//过滤状态条模式

this.ASPxGridView1.Settings.ShowFilterRow = true;//是否过滤行

this.ASPxGridView1.Settings.ShowFilterRowMenu = true;//是否显示过滤菜单

this.ASPxGridView1.SettingsBehavior.AutoFilterRowInputDelay = 1000;//自动过滤时间间隔(单位:毫秒,默认值:1200) (3)设置FilterExpression过滤表达式

这是最灵活的一种的方法,可以使用任何有效过滤表达式(包括值比较操作符、逻辑运算符) 例:

LogID > 23955 and Event like '%审核%' 2.数据搜索

(1) FindVisibleIndexByKeyValue

语法:int FindVisibleIndexByKeyValue(object keyValue) 例: //搜索

protected void btnFindKeyValue_Click(object sender, EventArgs e) {

string keyValue = this.txtFindKeyValue.Text; int logID;

if (keyValue.Length > 0 && Int32.TryParse(keyValue,out logID)) {

int rowIndex =

this.ASPxGridView1.FindVisibleIndexByKeyValue(logID); if (rowIndex >= 0) {

this.ASPxGridView1.Selection.UnselectAll();//取消所有行的选择

this.ASPxGridView1.Selection.SelectRow(rowIndex);//选中指定行

this.ASPxGridView1.FocusedRowIndex = rowIndex; this.ASPxGridView1.MakeRowVisible(logID); } } }

十三、 分页

AspxGridView默认支持分页,默认每页行数(PageSize)是10。如果不想分页,可以设置SettingsPager的Mode=” ShowAllRecords”。可以通过访问SettingsPager读取或更改相关分页属性。 1.分页条相关属性

属性名 数据类型 英文说明 中文说明

AlwaysShowPager bool Gets or sets whether the Pager is displayed within the ASPxGridView when there is only on page. 是否总是显示分页条(即在一页时是否也显示分页条)。可读写

CurrentPageNumberFormat string Gets or sets the pattern used to format the text of the numeric button that corresponds to the selected

page. 当前页次数字格式。可读写。类似如下格式:{0:G}

EllipsisMode DevExpress.Web.ASPxPager.PagerEllipsisMode(枚

举) Gets or sets how an Ellipsis symbol(s) is drawn to indicate page numbers that are omitted. 获取或设置页码省略模式。可读写。

InsideNumeric:中间页码省略,None:不显示省略符,OutsideNumeric:两端页码省略

AllButton DevExpress.Web.ASPxPager.AllButtonProperties Gets the All button’s settings. 取所有分页条上按钮属性.只读

FirstPageButton DevExpress.Web.ASPxPager.FirstButtonProperties Gets the First button's settings. 获取首页按钮属性设置。只读。通常更改其显示文本、可见性、图片。

LastPageButton DevExpress.Web.ASPxPager.LastButtonProperties Gets the Last button's settings. 获取末页按钮属性设置。只读。通常更改其显示文本、可见性、图片。

PrevPageButton DevExpress.Web.ASPxPager.PrevButtonProperties Gets the Previous button's settings. 获取上页按钮属性设置。只读。通常更改其显示文本、可见性、图片。

NextPageButton DevExpress.Web.ASPxPager.NextButtonProperties Gets the Next button's settings. 获取下页按钮属性设置。只读。通常更改其显示文本、可见性、图片。

Mode GridViewPagerMode(枚举) Gets or sets whether page-mode navigation is enabled. 获取或设置是否分页。可读写。取值范围:

ShowPager,表示要求分页;ShowAllRecords,显示所有记录,实际上是不分页。 NumericButtonCount Int Gets or sets the maximum number of numeric buttons that can be

displayed within a paginated control. 获取或设置显示在分页条上的数字页码个数。可读写。

PageNumberFormat String Gets or sets the pattern used to format the text of numeric buttons. 数字页码格式。可读写。类似如下格式:{0:G}

PageSize Int Gets or sets the maximum number of rows that can be displayed on a

page. 每页行数。可读写。默认为10.

Position PagerPosition(枚举) Gets or sets the pager's position within an ASPxGridView control. 获取或设置分页条位置。可读写。取值范围:Top,Bottom, TopAndBottom.

SEOFriendly DevExpress.Web.ASPxPager.SEOFriendlyMode(枚举) Gets or sets whether Search-Engine Optimization (SEO) mode is enabled. 获取或设置搜索优化模式。可读写。取值范围:Enabled,启用;Disabled,不启用;CrawlerOnly,自动检测。

ShowDefaultImages bool Gets or sets whether default button images are shown. 获取或设置是否显示缺省的分页图片。可读写。只有本属性设置为true,分页按钮(如首页)的图片才能更改生效。

ShowDisabledButtons Bool Gets or sets whether navigation buttons

that are temporarily disabled are shown. 获取或设置当分页按钮无效时是否隐藏。可读写。

ShowNumericButtons Bool Gets or sets whether numeric buttons are visible. 获取或设置数字页码是否可见。可读写。

ShowSeparators Bool Gets or sets whether separators that separate page numbers are shown. 获取或设置页码间是否放置分隔条(|)。可读写。

Summary DevExpress.Web.ASPxPager.SummaryProperties Gets the control's Summary settings. 获取分页控件汇总属性。只读。

Visible Bool Gets or sets whether the pager is visible. 获取或设置分页条是否可见。可读写。

其中以下属性通常会被访问或重置。PageSize、各分页按钮文本。 2.更改分页条按钮属性

分页工具条上一般有首页(FirstPageButton)、上页(PrevPageButton)、下页(NextPageButton)、末页(LastPageButton)按钮。通常会对按钮的文本进行本地化。 例:

this.ASPxGridView1.SettingsPager.FirstPageButton.Text = \首页\this.ASPxGridView1.SettingsPager.FirstPageButton.Visible = true; this.ASPxGridView1.SettingsPager.PrevPageButton.Text = \上一页\this.ASPxGridView1.SettingsPager.NextPageButton.Text = \下一页\this.ASPxGridView1.SettingsPager.LastPageButton.Text = \末页\this.ASPxGridView1.SettingsPager.LastPageButton.Visible = true; 3.与分页相关操作

(1)跳页: this.ASPxGridView1.PageIndex=<指定页号> (2)取总页数:this.ASPxGridView1.PageCount (3)页次改变事件PageIndexChanged

如果AspxGridView是动态绑定数据源,必须在翻页事件(PageIndexChanged)中重新绑定数据,否则翻页后无数据。

void ASPxGridView1_PageIndexChanged(object sender, EventArgs e) 十四、 客户端排序 1.使用SortBy方法排序

语法1:void SortBy(ASPxClientGridViewColumn column); 语法2:void SortBy(int columnIndex);

语法3:void SortBy(string columnFieldNameOrId);

语法4:void SortBy(string columnFieldNameOrId, string sortOrder); 语法5:void SortBy(ASPxClientGridViewColumn column,string sortOrder); 语法6:void SortBy(int columnIndex, string sortOrder);

语法7:void SortBy(int columnIndex, string sortOrder,bool reset); 语法8:void SortBy(ASPxClientGridViewColumn column,string sortOrder, bool reset);

语法9:void SortBy(string columnFieldNameOrId, string sortOrder, bool reset);

语法10:void SortBy(ASPxClientGridViewColumn column,string sortOrder,