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);

CxGrid筛选自动添加百分号和默认旧的滚动条样式的更多相关文章

  1. chrome浏览器当表单自动填充时,怎么去除浏览器自动添加的默认样式。

    参考blog来自 http://segmentfault.com/q/1010000000671971 chrome浏览器当表单自动填充时,怎么去除浏览器自动添加的默认样式. 一.发现该问题的原因-是 ...

  2. WordPress发布文章/页面时自动添加默认的自定义字段

    如果你每篇文章或页面都需要插入同一个自定义字段和值,可以考虑在WordPress发布文章/页面时,自动添加默认的自定义字段.将下面的代码添加到当前主题的 functions.php 即可: 1 2 3 ...

  3. sql server小技巧-自动添加时间与主键自增长

    在敲机房收费系统的时候,遇到添加时间的时候总是通过vb端调用当前时间再添到sql server中,期间还有时因为添加时间格式的不统一导致一些小问题,现在才知道原来是自己孤陋寡闻,sql server ...

  4. Javascript禁止网页复制粘贴效果,或者复制时自动添加来源信息

    一.禁止复制 使用方法:在oncopy事件中return false oncopy="return false;" 1.禁止复制网页内容 <body oncopy=" ...

  5. sublime 设置新建文件自动添加author(作者)等文件头信息

    很多时候, sublime 自带自动添加文件头信息, 但是并不是我们想要比如下面这样的:新建一个python文件 自动添加的author 信息== 上面并不是我想要的, 我想要下面这样的效果:== 这 ...

  6. CentOS 7 实现zabbix agent 自动添加,并链接到指定的模版

    如果添加的agent端数量较少时 , 手动添加还是可以的 , 如果数量较多 , 那么zabbix-server 的Discovery自动发现功能便派上了用场 首先所需要加入的服务器zabbix-age ...

  7. python logging详解及自动添加上下文信息

    之前写过一篇文章日志的艺术(The art of logging),提到了输出日志的时候记录上下文信息的重要性,我认为上下文信息包括: when:log事件发生的时间 where:log事件发生在哪个 ...

  8. 为C函数自动添加跟踪语句

    目录 为C函数自动添加跟踪语句 声明 一. 问题提出 二. 代码实现 2.1 函数匹配测试 2.2 插入跟踪语句 三. 效果验证 为C函数自动添加跟踪语句 标签: Python 正则表达式 声明 本文 ...

  9. mybatis JdbcTypeInterceptor - 运行时自动添加 jdbcType 属性

    上代码: package tk.mybatis.plugin; import org.apache.ibatis.executor.ErrorContext; import org.apache.ib ...

随机推荐

  1. windows下git的使用方法(码云)

    这表文章主要是用了可视化操作: 使用命令行操作:https://www.cnblogs.com/mswyf/p/9370238.html 一.安装Git Bash 为了在windows下使用Git,我 ...

  2. POJ 3169.Layout 最短路

    Layout Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11612   Accepted: 5550 Descripti ...

  3. id不连续

    解决办法 Alter TABLE jf_day_pv_classify Drop id; Alter TABLE jf_day_pv_classify ADD id INT NOT NULL PRIM ...

  4. Laravel Many to Many Polymorphic Relationship

    Many to many Polymorphic relationship is also a little bit complicated to understand. For example, i ...

  5. 动态代理jdk和cglib的区别

    学习来源贴:http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html JDK实现动态代理需要实现类通过接口定义业务方法,对于没有接口的类, ...

  6. 为什么要用jvm .

    挚享科技 2018.4.8 运行java程序字节码,实现跨平台.. Java语言使用Java虚拟机屏蔽了与具体平台相关的信息,使得Java语言编译程序只需生成 在Java虚拟机上运行的目标代码(字节码 ...

  7. linux下设置mysql表名不区分大小写

    原文:http://blog.csdn.net/johnsonvily/article/details/6703902 1.Linux下mysql安装完后是默认:区分表名的大小写,不区分列名的大小写: ...

  8. JS基础-数据类型-运算符和表达式-变量和常量

    1.js的基础语法2.js调试 1.F12调出控制台,查看提示错误及其位置. 2.出错时只影响当前代码块,不会影响其他代码块,后续代码块继续执行.3.语法规范 1.js语句:可执行的最小单元 必须以 ...

  9. 字符串方法 split() & replace()

    split() 语法:stringObject.split(separator) 功能:把一个字符串分割成字符串数组 返回值:Array 说明:separator 是必须的,分隔符. var str= ...

  10. 使用delphi-cross-socket 开发kbmmw smart http service

    前几天我说了使用delphi-cross-socket 扩展kbmmw 的跨平台支持,今天我说一下使用 kbmMWCrossScoketHttpServerTransport 在linux 下支持 k ...