设定Grid行的颜色
有时候需要根据某些单据的值设定不同的颜色,AX中FormDataSource的displayOption方法可是实现这个需求,只要重载一下这个方法即可。
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesTable localSalesTable;
;
localSalesTable = _record;
_options.fontBold(true);
if(localSalesTable.CustAccount == '4000')
{
//_options.affectedElementsByField(FieldNum(SalesTable,salesId));
_options.affectedElementsByControl(SalesTable_CustAccountAdv.id());
_options.backColor(WinAPI::RGB2int(255,0,0));
_options.textColor(WinAPI::RGB2int(255,255,0));
}
else
{
_options.backColor(WinAPI::RGB2int(255,255,255));
}
super(_record, _options);
}
其中方法affectedElementByControl可以设定某个控件的背景和字体颜色,本来按照字面意思affectedElementsByField应该可以按照字段设定颜色,不过偶试了一下貌似不可以,不知道是俺的做法不对还是AX没有实现,另外FormRowDisplayOption的Font*方法也不起作用,不知道是怎么回事。
{
SalesTable localSalesTable;
;
localSalesTable = _record;
_options.fontBold(true);
if(localSalesTable.CustAccount == '4000')
{
//_options.affectedElementsByField(FieldNum(SalesTable,salesId));
_options.affectedElementsByControl(SalesTable_CustAccountAdv.id());
_options.backColor(WinAPI::RGB2int(255,0,0));
_options.textColor(WinAPI::RGB2int(255,255,0));
}
else
{
_options.backColor(WinAPI::RGB2int(255,255,255));
}
super(_record, _options);
}