背景颜色行
Background color row
我在表单的数据源上创建了一个显示方法来检查某个字段是否匹配,如果有 2 个相同的值,表单中的特定行应该有背景色。
下面代码的问题是表单中的所有行都被赋予了背景色,即使只有 1 行记录匹配。
我做错了什么?
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineLocal;
;
salesLineLocal = _record;
while select salesLineLocal
where salesLineLocal.SerialId == salesLine.SerialId
if(salesLineLocal.RecId != SalesLine.RecId)
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
}
修改你的方法如下,这将工作正常:
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineCurrent;
SalesLine salesLineLocal;
;
salesLineCurrent = _record;
select firstOnly RecId from salesLineLocal
where salesLineLocal.SerialId == salesLineCurrent.SerialId
&& salesLineLocal.RecId != salesLineCurrent.RecId;
if (salesLineLocal.RecId)
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
super(_record, _options);
}
但如果您想改进它,您可以在 table 级别上移动验证逻辑。在 SalesLine
table 上创建方法
public boolean hasDupplicate()
{
SalesLine salesLine;
;
select firstOnly RecId from salesLine
where salesLine.SerialId == this.SerialId
&& salesLine.RecId != this.RecId;
return salesLine.RecId != 0
}
然后你的 displayOption
方法看起来像
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineLocal;
;
salesLineLocal = _record;
if (salesLineLocal.hasDupplicate())
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
super(_record, _options);
}
我在表单的数据源上创建了一个显示方法来检查某个字段是否匹配,如果有 2 个相同的值,表单中的特定行应该有背景色。
下面代码的问题是表单中的所有行都被赋予了背景色,即使只有 1 行记录匹配。
我做错了什么?
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineLocal;
;
salesLineLocal = _record;
while select salesLineLocal
where salesLineLocal.SerialId == salesLine.SerialId
if(salesLineLocal.RecId != SalesLine.RecId)
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
}
修改你的方法如下,这将工作正常:
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineCurrent;
SalesLine salesLineLocal;
;
salesLineCurrent = _record;
select firstOnly RecId from salesLineLocal
where salesLineLocal.SerialId == salesLineCurrent.SerialId
&& salesLineLocal.RecId != salesLineCurrent.RecId;
if (salesLineLocal.RecId)
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
super(_record, _options);
}
但如果您想改进它,您可以在 table 级别上移动验证逻辑。在 SalesLine
table 上创建方法
public boolean hasDupplicate()
{
SalesLine salesLine;
;
select firstOnly RecId from salesLine
where salesLine.SerialId == this.SerialId
&& salesLine.RecId != this.RecId;
return salesLine.RecId != 0
}
然后你的 displayOption
方法看起来像
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesLine salesLineLocal;
;
salesLineLocal = _record;
if (salesLineLocal.hasDupplicate())
{
_options.backColor(Winapi::RGB2int(251,181,251));
}
super(_record, _options);
}