表格颜色 字段颜色 字段背景色
1.在FORM数据源下,覆盖方法displayOption();
2.覆盖数据源的Write()方法:在Super之后写入 GridColours_ds.clearDisplayOption(gridColours);
处出关键地方是:affectedElementsByControl()方法。
public void displayOption(Common _record, FormRowDisplayOption _options)
{
GridColours gridColoursLocal = _record;
;
super(_record, _options);
// If highlight flag is set, then give the entire row a black background/white text
if (gridColoursLocal.Highlight) //Highlight是一个字段,当被勾选后显示黄色
{
_options.backColor(WinApi::RGB2int(255,255,0)); // Yellow
}
else
{
if (gridColoursLocal.RequestedDate < systemDateGet() || gridColoursLocal.ConfirmedDate > gridColoursLocal.RequestedDate)
{
_options.backColor(WinApi::RGB2int(255,0,0)); // Red
_options.textColor(WinApi::RGB2int(255,255,255)); // White text
if (gridColoursLocal.RequestedDate < systemDateGet())
{
// Applies only to the RequestedDate field on the grid
_options.affectedElementsByControl(Grid_RequestedDate.id()); //此处重要; 指定受影响的范围仅是Grid中的列
}
if (gridColoursLocal.ConfirmedDate > gridColoursLocal.RequestedDate)
{
// Applies only to the RequestedDate field on the grid
_options.affectedElementsByControl(Grid_ConfirmedDate.id()); //同上,如果没有则会整行都上色
}
}
}
}