Jump to content

Custom Draw UniDBGrid rows


enix

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
Share on other sites

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! :)

Link to comment
Share on other sites

  • 2 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...