Jump to content

Recommended Posts

Posted

Hi,

 

How to set font attributes for whole row instead of particular cells ?

OnDrawColumnCell event allows check value of field in current drawing column. Is possible to get value from another column of the same row ?

 

reg. Piotrek Pawlak

Posted

OnDrawColumnCell event allows check value of field in current drawing column. Is possible to get value from another column of the same row ?

 

 

If you're using a data-aware TDataset descendent, just read the value from the dataset.

 

Here I'm using the status field to set the background color for all cells in a row.

 

procedure TfMain.UniDBGrid1DrawColumnCell(Sender: TObject; ACol, ARow: Integer;
 var Value: string; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin
 If DataModule1.ISSUES_Tissue_status.AsString = 'Closed' then
   attribs.Color := clRed;
end;

so if the issue is closed, the row is red. Just be aware , the more you do this, the more it impacts performance.

 

example 2: This will change the row font :

 

procedure TfMain.UniDBGrid1DrawColumnCell(Sender: TObject; ACol, ARow: Integer;
 var Value: string; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin

 If DataModule1.ISSUES_Tissue_status.AsString = 'Researching' then
   attribs.Font.Color := clRed;

end;

post-11-0-87186200-1309450398_thumb.png

post-11-0-48139100-1309451123_thumb.png

  • Upvote 1
  • 1 year later...
Posted

Use CSS background style or <img> HTML tag.

Thanks,

But I am a Delphi programmer and I am not familiar with javascript :(

Is it possible any sample?

 

Regards

Posted

Thanks,

But I am a Delphi programmer and I am not familiar with javascript :(

Is it possible any sample?

 

Regards

 

here you go, hope this helps. I have a calculated field in my dataset called ISSUES_TImageIcon.

I just set the text for that to a valid HTML tag and the browser knows how to render it in the grid.

 

 

procedure TDataModule1.ISSUES_TCalcFields(DataSet: TDataSet);
Var
aStatus : String;

begin
aStatus := Uppercase(ISSUES_TISSUE_STATUS.Value);
If aStatus = 'CLOSED' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/tick.bmp"/>'
Else if aStatus = 'RESEARCHING' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/research.bmp"/>'
Else if aStatus = 'REPORTED' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/reported.bmp"/>'
Else if aStatus = 'CAN CLOSE' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/flag_green.bmp"/>'
Else
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/open.bmp"/>' ;
end;

  • Like 1
  • Upvote 1
Posted

here you go, hope this helps. I have a calculated field in my dataset called ISSUES_TImageIcon.

I just set the text for that to a valid HTML tag and the browser knows how to render it in the grid.

 

 

procedure TDataModule1.ISSUES_TCalcFields(DataSet: TDataSet);
Var
aStatus : String;

begin
aStatus := Uppercase(ISSUES_TISSUE_STATUS.Value);
If aStatus = 'CLOSED' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/tick.bmp"/>'
Else if aStatus = 'RESEARCHING' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/research.bmp"/>'
Else if aStatus = 'REPORTED' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/reported.bmp"/>'
Else if aStatus = 'CAN CLOSE' then
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/flag_green.bmp"/>'
Else
  ISSUES_TImageIcon.Value := '<img width=16 height=16 src="images/open.bmp"/>' ;
end;

Thanks a lot!

I am happy! :)

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...