Show/Hide Controls in wwLayoutGrid
I am using a wwLayoutGrid to display repeating data in the grid. I use 3 layouts in the Layout Panel. I would like the layout panel to show/hide different layouts based on the data at runtime. In the CustomDrawControl procedure, I manipulate the Background color of the fields based on the actual data. This works very well and the background color on the fields are changed for ALL the records in the layout grid.
When I use the same logic to set the 'visible' property of one of the layouts, it only hides the layout on the 'Active' record. I am trying to hide the layout on ALL the records that meet a certain criteria.
Is there a way to hide a control for all the records that meet certain criteria and not just the 'Active' one? In the attached screen shot, I am hiding the 'Comment' Layout but the 'Comment' shows on all the records except the active one (Highlighted in blue). I tried visually binding a binary field to the 'visible' property of the layout but that didn't work either.
Following is my code and a sample screen:
procedure TDoorShopFrame.wwLayoutGrid1CustomDrawControl(Sender: TObject;
CellAttributes: TwwCustomDrawControlAttributes);
begin
if (CellAttributes.Control = edHeight) then
begin
loConfiguratorComment.Visible := dmDoorShopClient.FDMTConfigurator.FieldByName('Additional').AsBoolean;
if (dmDoorShopClient.FDMTConfigurator.FieldByName('Height').AsString <> '6'' 8"') then
begin
CellAttributes.BackColor:= TAlphaColorRec.Navy;
CellAttributes. FontColor:= TAlphaColorRec.White;
end
else
CellAttributes.FontColor:= TAlphaColorRec.Black;
end
else
if (CellAttributes.Control = edLH)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('LHQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.Yellow
else
if (CellAttributes.Control = edRH)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('RHQty').AsInteger > 0) then
CellAttributes.BackColor := TAlphaColorRec.Pink
else
if (CellAttributes.Control = edDD)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('DDQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.Orange
else
if (CellAttributes.Control = edSlab)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('SlabQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.LightSkyBlue
else
if (CellAttributes.Control = edJamb)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('Jamb').AsString <> '')
and (not dmDoorShopClient.FDMTConfigurator.FieldByName('DEFAULT_JAMB').AsBoolean) then
CellAttributes.BackColor:= TAlphaColorRec.Lime
else
if (CellAttributes.Control = edFBRCMC)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('DDQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.Orange
else
if (CellAttributes.Control = edDrilling)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('DDQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.Orange
else
if (CellAttributes.Control = edBF)
and (dmDoorShopClient.FDMTConfigurator.FieldByName('BFQty').AsInteger > 0) then
CellAttributes.BackColor:= TAlphaColorRec.Purple;
end;

-
I think you can just set the CellAttributes property. For instance our main demo does something like this
if (CellAttributes.Control=lblNewFeatures) or
(CellAttributes.Control=lblChildNewFeatures) then
begin
if not (CellAttributes.GetValue('NewFeatures').AsBoolean) then
CellAttributes.DoDefaultDrawContents:=false;
end;This prevents the painting of the control for each row (except the active when readonly=false)
This works well if your ReadOnly is true for the grid. However if readonly is false, then the actual control is painted for the row so you may also need to set the visible property of the actual control in the event just like you are already doing.
Please sign in to leave a comment.
Comments
1 comment