[英]When uniQuery is opened, why DataSource.onDataChange trigger 2 times?
I've a question about unidac's uniQuery
: 我对unidac的
uniQuery
有疑问:
when uniQuery
open, if a DataSource
component is linked, the DataSource.onDataChange
will trigger 2 times, and ADOQuery
trigger just 1 time, why? 当
uniQuery
打开时,如果链接了DataSource
组件,则DataSource.onDataChange
将触发2次,而ADOQuery
仅触发1次,为什么?
Environment: 环境:
I faced the same problem many times, I found that it is a default loading behavior not just in the Uni-component, all similar database components will trigger .onDataChange
twice or more when loading, the only way to go over it is by using workarounds to ignore the 1st trigger. 我多次遇到相同的问题,我发现这是默认的加载行为,不仅是在Uni组件中,所有类似的数据库组件在加载时都会触发
.onDataChange
两次或更多次,唯一的解决方法是使用变通办法忽略第一个触发器。
You can find also a similar problem here 您也可以在这里找到类似的问题
If triggering twice is annoying you, try my workaround for it: 如果触发两次让您感到烦恼,请尝试以下解决方法:
var c: integer; // must be global and reset to 0 when u close your query
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
if c = 2 then
begin
// do your actions
end
else
begin
inc(c);
end;
end;
It will eliminate all none necessary triggers, 它将消除所有不必要的触发器,
hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.