CxGrid筛选自动添加百分号和默认旧的滚动条样式

2018-10-29

约 693 字  预计阅读 2 分钟

【注意】最后更新于 2 months ago,文中内容可能已过时,请谨慎使用。

cxGrid支持使用like过滤时自动添加百分号

默认状态下, 不会添加 %% 到过滤串中, 修改源码如下

cxFilter.pas 在 \Library\Sources\cxFilter.pas 和 \ExpressDataController\Sources\cxFilter.pas 两个地方都有一个,一起修改掉

cxFilter.pas 的 TcxFilterCriteria.AddItem 改成这样

1
2
3
4
5
6
7
8
9
//if AParent = nil then
// AParent := Root;
//Result := AParent.AddItem(AItemLink, AOperatorKind, AValue, ADisplayValue);
if AParent = nil then
AParent := Root;
if AOperatorKind in [foLike, foNotLike] then
Result := AParent.AddItem(AItemLink, AOperatorKind, '%' + AValue + '%', ADisplayValue)
else
Result := AParent.AddItem(AItemLink, AOperatorKind, AValue, ADisplayValue);

cxFilterDialog.pas 在 Library\Sources\cxFilterDialog.pasExpressQuantumGrid\Sources\cxFilterDialog.pas

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// TcxFilterDialog.AddFilterItem
 
procedure TcxFilterDialog.AddFilterItem(AParent: TcxFilterCriteriaItemList;
AComboBox: TcxComboBox; AValue: Variant; ADisplayValue: string);
var
AOperator: TcxFilterControlOperator;
begin
AOperator := GetOperator(AComboBox);
if AOperator = fcoNone then Exit;
 
//edited by lero 09-11-18 如果是like,而且没有输入%时,自动在前后加入%
if AOperator in [fcoLike, fcoNotLike] then
begin
if VarIsStr(AValue) and (AValue <> '') and (Pos('%', AValue) = 0) then
AValue := '%' + AValue + '%';
end;
 
if AOperator in [fcoBlanks, fcoNonBlanks] then
AValue := Null;
if VarIsNull(AValue) or (VarIsStr(AValue) and (AValue = '')) then
ADisplayValue := cxGetResourceString(@cxSFilterBlankCaption);
 
Criteria.AddItem(AParent, ItemLink, GetFilterOperatorKind(AOperator), AValue, ADisplayValue);
end;

DevExpress控件滚动条默认使用旧的经典滚动条样式

新版本, 应该是17还是多少版本开始,默认使用触摸的滚动条样式, 查询了官方的论坛之后, 可以修改如下

搜索cxVer.inc 在 \Library\Sources\cxVer.inc 和 \ExpressCore Library\Sources\cxVer.inc 两个地方各有一个

打开后, 搜索 USETOUCHSCROLLUIMODEASDEFAULT 在 $DEFINE 前面加个点即可

1
{.$DEFINE USETOUCHSCROLLUIMODEASDEFAULT}

DevExpress下拉lookup控件加入输入时自动定位

  • 单元 cxCustomData.pas Library\Sources\cxCustomData.pasExpressDataController\Sources\cxCustomData.pas 修改如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function TcxCustomDataController.DoIncrementalFilterRecord(ARecordIndex: Integer): Boolean;
var
S: string;
I: Integer;
begin
//edited by lero---
Result := False;
for I := 0 to Fields.ItemCount - 1 do
begin
S := GetInternalDisplayText(ARecordIndex, Fields[i]);
Result := DataCompareText(S, FIncrementalFilterText, True);
if Result then
begin
FDisplayIndex := i;
Exit;
end;
end;
//S := GetInternalDisplayText(ARecordIndex, FIncrementalFilterField);
//Result := DataCompareText(S, FIncrementalFilterText, True, FIncrementalFilteringFromAnyPos);
end;

SortingBySummaryDataItemIndex属性下方添加, 不要忘了在private节下加入 FDisplayIndex:Integer;

1
property DisplayIndex: Integer read FDisplayIndex write FDisplayIndex; //add by lero
  • 单元 cxLookupEdit.pas 分别在 Library\Sources\cxLookupEdit.pas 和 ExpressEditors Library\Sources\cxLookupEdit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// TcxCustomLookupEditLookupData.Locate
 
 
if ARecordIndex <> -1 then
begin
DataController.ChangeFocusedRecordIndex(ARecordIndex);
DoSetCurrentKey(ARecordIndex);
Result := True;
//此处为添加代码 add by lero---
if DataController.DisplayIndex > -1 then
begin
S := DataController.DisplayTexts[ARecordIndex, DataController.DisplayIndex];
DataController.DisplayIndex := -1;
end
else
begin
S := DataController.DisplayTexts[ARecordIndex, AItemIndex];
end;
//结束
//S := DataController.DisplayTexts[ARecordIndex, AItemIndex];
if IsLikeTypeFiltering then
ATail := ''
else
begin
AText := Copy(S, 1, Length(AText));
ATail := Copy(S, Length(AText) + 1, Length(S));
end;
DoSetKeySelection(True);
end
else
DoSetKeySelection(False);

最新文章

  1. LUA table学习笔记
  2. 对atime、mtime和ctime的研究
  3. hdu------(3549)Flow Problem(最大流(水体))
  4. Car immobilizer hacking
  5. CentOS上firefox安装flash
  6. Cesium的api之关于viewer(二)
  7. DTD简单使用
  8. LoadRunner录制回放脚本RecContentType=application/json报错
  9. android 简单粗暴的注解初始化View学习
  10. 笔记-Python基础教程(第二版)第一章
  11. Python学习之一:Python2.7与opencv2.4安装配置
  12. 算法提高 金属采集_树形dp
  13. 1.4 Chrome浏览器
  14. ##Truncated incorrect DOUBLE value: &#39;E#4&#39; 的问题解决
  15. 大数据入门第二十二天——spark(二)RDD算子(1)
  16. tensorflow之曲线拟合
  17. zookeeper是如何选取主leader的?
  18. 【算法笔记】B1033 旧键盘打字
  19. mac系统安装mysql
  20. Python数据报协议以及sockersever模块的使用

热门文章

  1. rap2与postman自动化测试
  2. Vue组件中引入jQuery
  3. js jquery 取得周月年时间
  4. mybatis学习四 mybatis的三种查询方式
  5. System.load()与System.loadLibrary()
  6. GUI的最终选择Tkinter模块练习篇
  7. unity中的构造函数
  8. SELECT INTO创建临时表
  9. 将项目部署到 github上(部署到码云操作一样,前提是有码云账号)
  10. linux 修改yum 为阿里云源