当前位置:网站首页>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 边栏推荐
- Implement the rising edge in C #, and simulate the PLC environment to verify the difference between if statement using the rising edge and not using the rising edge
- 运算符、、
- 如何将 DevSecOps 引入企业?
- 32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)
- Detailed explanation of MATLAB cov function
- DDR4的特性与电气参数
- Variables///
- BOM//
- How to close the log window in vray5.2
- Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
猜你喜欢

Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?

在C# 中实现上升沿,并模仿PLC环境验证 If 语句使用上升沿和不使用上升沿的不同

Basic testing process of CSDN Software Testing Introduction

关于vray 5.2的使用(自研笔记)

Lombok 同时使⽤@Data和@Builder 的坑,你中招没?

Based on shengteng AI Aibi intelligence, we launched a digital solution for bank outlets to achieve full digital coverage of information from headquarters to outlets

Detailed explanation of MATLAB cov function

Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework

小红书自研KV存储架构如何实现万亿量级存储与跨云多活

32:第三章:开发通行证服务:15:浏览器存储介质,简介;(cookie,Session Storage,Local Storage)
随机推荐
DGL中的消息传递相关内容的讲解
R3Live系列学习(四)R2Live源码阅读(2)
How to introduce devsecops into enterprises?
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
Stop saying that microservices can solve all problems!
About the use of Vray 5.2 (self research notes)
Paradigm in database: first paradigm, second paradigm, third paradigm
Web Components
Taro advanced
第五届 Polkadot Hackathon 创业大赛全程回顾,获胜项目揭秘!
在C# 中实现上升沿,并模仿PLC环境验证 If 语句使用上升沿和不使用上升沿的不同
DOM//
Bidirectional RNN and stacked bidirectional RNN
String
中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
About the use of Vray 5.2 (self research notes)
磨礪·聚變|知道創宇移動端官網煥新上線,開啟數字安全之旅!
Detailed explanation of MATLAB cov function
【Oracle】使用DataGrip连接Oracle数据库