Delphi中使用cxGrid对数据集进行Sort和Locate操作
来源:互联网 发布:手机淘宝怎样更新 编辑:程序博客网 时间:2024/06/15 08:06
Delphi中使用cxGrid对数据集进行Sort和Locate操作
在编写某个系统时,由于使用了数据集类型无关技术(即数据集可能是ADOQuery,也有可能是TClientDataSet等等)。当需要对数据进行排序和查找时,只好利用cxGrid自身的功能来实现:
function GridSortColumn(View : TcxGridDBTableView; FieldName : String) : Boolean;
var
i : Integer;
begin
{数据排序}
Result := False;
for i := 0 to View.ColumnCount -1 do
begin
if (UpperCase(View.Columns[i].DataBinding.FieldName) = FieldName) then
begin
View.Columns[i].SortIndex := 0;
View.Columns[i].SortOrder := soAscending;
Result := True;
end
else
begin
View.Columns[i].SortIndex := -1;
View.Columns[i].SortOrder := soNone;
end;
end;
end;
function GridLocateRecord(View : TcxGridDBTableView; FieldName, LocateValue : String) : Boolean;
begin
{数据查找}
Result := False;
if (View.GetColumnByFieldName(FieldName) <> nil) then
Result := View.DataController.Search.Locate(View.GetColumnByFieldName(FieldName).Index, LocateValue);
end;
对于cxGrid排序后的数据集,不应该进行Next, Prior等操作,因为数据集的排序并没有变化,进行Next等操作时,会出现记录乱跳的情况,应该如下处理:
Prior:
DBView.DataController.FocusedRowIndex := DBView.DataController.FocusedRowIndex - 1;
Next:
DBView.DataController.FocusedRowIndex := DBView.DataController.FocusedRowIndex + 1;
- Delphi中使用cxGrid对数据集进行Sort和Locate操作
- 使用cxGrid对数据集进行Sort和Locate操作
- delphi中cxGrid使用技巧
- MySQL 使用locate函数对 GROUP_CONCAT 列进行 JOIN 操作
- 使用sort命令和awk命令对数据集的label进行处理
- Delphi中CxGrid控件使用总结
- delphi中cxGrid使用汇总(一)
- delphi中cxGrid使用汇总(二)
- delphi CxGrid使用小结
- 在Delphi中使用CreateOleObject方法对WORD文件进行操作
- 在Delphi中使用CreateOleObject方法对WORD文件进行操作
- Delphi对并口进行操作!
- 使用jq对表格数据进行操作
- java中使用sort()对ArrayList进行排序
- delphi中cxgrid和数据库搭配的基本应用
- php7中使用mongoDB的聚合操作对数据进行分组求和统计操作
- delphi中locate方法
- 使用knn和logsitic对make_blobs数据集进行分类
- 系统架构--设计模式之“全局变量”
- epub格式的电子书
- HDU 1176
- strlen函数
- strcspn函数
- Delphi中使用cxGrid对数据集进行Sort和Locate操作
- 关于hibernate 的小总结
- strdup函数
- C#如何获取项目的根目录
- 漏洞与程序员
- Managing Space in Tablespaces【每日一译】--2012-11-02
- spring3.0注解注入
- Java多线程1-安全性、互斥与同步
- strlwr,strupr函数