View Full Version : How to change the cell background of a specific grid cell
hmischel@diligentsystems.com
2017-08-01, 12:42
Hi,
I have a grid bound to a table in a custom VFP Section.
As users fulfill different actions, I need to be able to change the color of specific cell backgrounds.
I know the cell I want, how do change the backcolor programmaticly ?
I have looked at Dynamic Cell Background, but this is not based on a table value.
would it be something along of the line of
sCell = namespace.grid.item(x,y)
sCell.backcolor='red'
Thanks
Herb
Have you tried:
sCell.backcolor={myfunction()}
Hank
hmischel@diligentsystems.com
2017-08-01, 15:05
Hi Hank,
No Luck there either.
Herb
Hi Hank,
No Luck there either.
Herb
You can use iif Statements on dynamic cell background, check grid formatting example.
double click on section attributes at the dynamic cell background you'll see
iif(employeeid=1,"lightgreen","")
or Employee ID column
dynamic cell background = iif( {} = 4, "red", "")
dynamic cell foreground = iif( {} = 4, "yellow", "")
I hope this helps.
hmischel@diligentsystems.com
2017-08-01, 20:11
Hi Luisc,
That works on a standard grid object.
In my case, I am using a custom VFP section and hand creating all of my objects.
Meaning - in my code, I use addobject(), so the attributes need to be exposed on a programmatic level.
Thanks
Herb
yvonne.milne
2017-08-02, 08:27
Hi Herb,
As far as I am aware, you can access the backcolor and forecolor of the column (https://www.lianja.com/doc/index.php/Column), but not an individual cell.
Grid (https://www.lianja.com/doc/index.php/Grid).item(x,y) returns the text from a cell, not an object reference to the cell.
Maybe worth an enhancement request (https://lianja.com/support/newticket), since as you say columns in standard Grid Sections have the 'Cell dynamic background' and 'Cell dynamic foreground' attributes.
Regards,
Yvonne
hmischel@diligentsystems.com
2017-08-02, 13:27
Hi Yvonne,
Will do.
Herb