当前位置:网站首页>C # to obtain the filtered or sorted data of the GridView table in devaexpress
C # to obtain the filtered or sorted data of the GridView table in devaexpress
2022-07-05 11:09:00 【Milk coffee 13】
One 、 Requirements describe
At present, our business needs to obtain the right DevExpress in GridView Data content after filtering or sorting the table .
Two 、 Demand analysis
Direct access to GirdView The data content of the table is the first bound content , It will not change after filtering or sorting with the table control ; We can directly traverse the contents of the table to fill in the new DataTable Back in .
3、 ... and 、 Implementation method
#region Get the filtered or sorted data of the table
/// <summary>
/// obtain GridView Filtered or sorted dataset
/// </summary>
/// <typeparam name="T"> Generic class object </typeparam>
/// <param name="gridView">gridView Components </param>
/// <returns></returns>
public static IEnumerable<T> GetFilterOrSortDatasOfGridView<T>(DevExpress.XtraGrid.Views.Grid.GridView gridView) where T : class
{
var list = new List<T>();
for (int i = 0; i < gridView.RowCount; i++)
{
if (gridView.IsGroupRow(i))
continue;
var entity = gridView.GetRow(i) as T;
if (entity == null)
continue;
list.Add(entity);
}
return list;
}
/// <summary>
/// obtain GridView Filtered or sorted dataset
/// </summary>
/// <param name="gridView">gridView Components </param>
/// <returns></returns>
public static DataTable GetFilterOrSortDatasOfGridView(DevExpress.XtraGrid.Views.Grid.GridView gridView)
{
DataTable _dt = gridView.GridControl.DataSource as DataTable;
if (_dt == null) return null;
DataTable dt = _dt.Clone();
for (int i = 0; i < gridView.RowCount; i++)
{
if (gridView.IsGroupRow(i))
continue;
var dr = gridView.GetDataRow(i);
if (dr == null)
continue;
dt.Rows.Add(dr.ItemArray);
}
return dt;
}
#endregion
边栏推荐
- 数组、、、
- Scaffold development foundation
- Three paradigms of database
- DDR4硬件原理图设计详解
- Data type
- [JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
- Repair animation 1K to 8K
- How to close the log window in vray5.2
- Wechat nucleic acid detection appointment applet system graduation design completion (6) opening defense ppt
- go语言学习笔记-初识Go语言
猜你喜欢
Go language learning notes - first acquaintance with go language
Stop saying that microservices can solve all problems!
Web3 Foundation grant program empowers developers to review four successful projects
DGL中异构图的一些理解以及异构图卷积HeteroGraphConv的用法
matlab cov函数详解
九、磁盘管理
Detailed explanation of DDR4 hardware schematic design
如何将 DevSecOps 引入企业?
Wechat nucleic acid detection appointment applet system graduation design completion (8) graduation design thesis template
Based on shengteng AI Yisa technology, it launched a full target structured solution for video images, reaching the industry-leading level
随机推荐
Wechat nucleic acid detection appointment applet system graduation design completion (8) graduation design thesis template
Characteristics and electrical parameters of DDR4
Advanced scaffold development
Three suggestions for purchasing small spacing LED display
中职组网络安全2021年江苏省省赛题目5套题目环境+解析全有需要的私信我
GBase 8c数据库如何查看登录用户的登录信息,如上一次登录认证通过的日期、时间和IP等信息?
R3live series learning (IV) r2live source code reading (2)
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本
关于vray 5.2的使用(自研笔记)
msfconsole命令大全,以及使用说明
2021 Shandong provincial competition question bank topic capture
Function///
Go-3-the first go program
使用GBase 8c数据库过程中报错:80000502,Cluster:%s is busy,是怎么回事?
regular expression
Bracket matching problem (STL)
磨礪·聚變|知道創宇移動端官網煥新上線,開啟數字安全之旅!
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework