Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread change properties when filling grid
Mon, Oct 8 2018 7:48 PMPermanent Link

jdforce

Avatar

Hi,
I am getting a JSON with a TServerRequest, in the Complete Event.
Then I load the JSON to a dataset on the dataset.loadrows method.
Then dynamically I fill a grid, column by column with the data like so:

grid1.columns[0].header.caption := 'Device ID';
grid1.columns[0].dataColumn := 'deviceid';
grid1.columns[0].width := 80;

It works good, but I want to change the color for a row according to the value of one of the fields.  The change of color of course must be paired with the value if I click on the column title to sort up or down.

I have not found  a way to accomplish this, and need some example or suggestion please.
JD
Tue, Oct 9 2018 1:12 PMPermanent Link

jdforce

Avatar

jdforce wrote:
Actually the new requirement I was given is to color a single cell, containing a number, depending on the number it will be red, yellow or green. It is for alerting when some data is received.
Tue, Oct 9 2018 1:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< It works good, but I want to change the color for a row according to the value of one of the fields.  The change of color of course must be paired with the value if I click on the column title to sort up or down.  >>

What you want is this event:

https://www.elevatesoft.com/manual?action=viewevent&id=ewb2&comp=TGridColumn&event=OnCellUpdate

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Oct 10 2018 6:15 AMPermanent Link

Uli Becker

> Actually the new requirement I was given is to color a single cell, containing a number, depending on the number it will be red, yellow or green. It is for alerting when some data is received.

In addition to Tim's hint, here a sample how to read the cell's data within the OnCellUpdate event:

   if ACell.Data = '0' then
   begin
      ACell.Font.Color := clRed;
      ACell.Font.Style.Bold := true;
   end
   else
   begin
      ACell.Font.Color := clBlack;
      ACell.Font.Style.Bold := false;
   end;

Uli
Thu, Oct 11 2018 3:00 PMPermanent Link

jdforce

Avatar

Thanks guys, will test that ASAP.
Image