xsharp.eu • bBrowser ColorCondition not working
Page 1 of 1

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 6:55 am
by Anonymous
Sorry again, but what am I doing wrong here please? I've looked in the bBrowser help file, and the example .AEF file, but I still can't get it to work.

This is the postinit code I'm currently attempting:

method PostInit(oWindow,iCtlID,oServer,uExtra) class TheGreenScreen
Local oColorCondition as bColorCondition
Local oColumn as bDataColumn

//Put your PostInit additions here
oServer := DETAILS{}
oServer:SetOrder("JOBFINNO")
oServer:GoTop()

oColorCondition := bColorCondition{"oServer:JobFin = .t.", oServer, Color{COLORRED}}
oColumn := self:oDCbBrowser1:GetColumn(#JOBFIN)
oColumn:ColorCondition:Add(oColorCondition)
self:oDCComboBox1:CurrentItemNo := 1
self:oDCbBrowser1:Use(oServer,{#JobDate, #JOBNUMBER, #CLCODE, #CLNAME, #JOBTIME, #JOBDETAILS, #PONUMBER, #RATE, #UNITS, #RATETYPE, #NPC, #JOBFIN, #REGO, #SUBBY, #INVOICED, #INVFILE, #MAPFILE })
self:oDCbBrowser1:GetColumn(#JobDate):Width := 90
self:oDCbBrowser1:GetColumn(#JOBNUMBER):Width := 95
self:oDCbBrowser1:GetColumn(#CLCODE):Width := 90
self:oDCbBrowser1:GetColumn(#CLNAME):Width := 400
self:oDCbBrowser1:GetColumn(#JOBTIME):Width := 80
self:oDCbBrowser1:GetColumn(#JOBDETAILS):Width := 450
self:oDCbBrowser1:GetColumn(#RATE):Width := 90
self:oDCbBrowser1:GetColumn(#UNITS):Width := 90
self:oDCbBrowser1:GetColumn(#RATETYPE):Width := 100
self:oDCbBrowser1:GetColumn(#PONUMBER):Width := 160
self:oDCbBrowser1:GetColumn(#NPC):Width := 500
self:oDCbBrowser1:GetColumn(#JOBFIN):Width := 100
self:oDCbBrowser1:GetColumn(#REGO):Width := 500
self:oDCbBrowser1:GetColumn(#SUBBY):Width := 500
self:oDCbBrowser1:GetColumn(#INVOICED):Width := 100
self:oDCbBrowser1:GetColumn(#INVFILE):Width := 500
self:oDCbBrowser1:GetColumn(#MAPFILE):Width := 500

self:oDCbBrowser1:Refresh()
self:oDCbBrowser1:Recalculate()

self:oDCbBrowser1:SetFocus()
uExtra := self:oDCbBrowser1:Server:FIELDGET(#JOBNUMBER)
return uExtra


The aim of this exercise is to highlight EITHER the entire row, or just the JOBFIN cell based on if JOBFIN (logic field) is TRUE. If True highlight in RED in this example, if not, and JOBFIN is FALSE, leave it alone.

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 7:25 am
by lumberjack
Hi Jeff,
BiggyRat wrote:

Code: Select all

oColorCondition := bColorCondition{"oServer:JobFin = .t.", oServer, Color{COLORRED}}
Long time since I worked with bBrowser, but here is a conditional from a code snippet out some old code:

Code: Select all

oBrowser:ColorCondition:Add(;
bColorCondition{'Server:ContractNo = 0 .AND. Server:AutoFormNo = 0', oServer, , Brush{Color{COLORRED}}})
oBrowser:ColorCondition:Add(bColorCondition{'Server:ContractNo > 0', oServer, , Brush{Color{COLORGREEN}}})
oBrowser:ColorCondition:Add(;
bColorCondition{'Server:ContractNo = 0 .AND. Server:AutoFormNo > 0', oServer, , Brush{Color{COLORBLUE}}})
I think the only problem you have is oServer instead of Server in your ColorCondtion codeblock string, and you need a Brush for the color, if I compare the code...

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 8:49 am
by BiggyRat
Thank you Johan, but that didn't work. Here's my revised code:

method PostInit(oWindow,iCtlID,oServer,uExtra) class TheGreenScreen
Local oColorCondition as bColorCondition
Local oColumn as bDataColumn

//Put your PostInit additions here
If IsNil(oServer)
oServer := DbServer{"Details"}
endif

oServer:SetOrder("JOBFINNO")
oServer:GoTop()

oColorCondition := bColorCondition{"Server:JobFin = .t.", oServer, , Brush{Color{COLORRED}}}
oColumn := self:oDCbBrowser1:GetColumn(#JOBFIN)
oDCbBrowser1:ColorCondition:Add(oColorCondition, {"Server:JobFin = .t.", oServer, , Brush{Color{COLORRED}}})
self:EnableSystemMenu(false)
self:oDCComboBox1:CurrentItemNo := 1
self:Caption := cAppVersion + " - Job Listing Screen"
self:oDCbBrowser1:Use(oServer,{#JobDate, #JOBNUMBER, #CLCODE, #CLNAME, #JOBTIME, #JOBDETAILS, #PONUMBER, #RATE, #UNITS, #RATETYPE, #NPC, #JOBFIN, #REGO, #SUBBY, #INVOICED, #INVFILE, #MAPFILE })
self:oDCbBrowser1:GetColumn(#JobDate):Width := 90
self:oDCbBrowser1:GetColumn(#JOBNUMBER):Width := 95
self:oDCbBrowser1:GetColumn(#CLCODE):Width := 90
self:oDCbBrowser1:GetColumn(#CLNAME):Width := 400
self:oDCbBrowser1:GetColumn(#JOBTIME):Width := 80
self:oDCbBrowser1:GetColumn(#JOBDETAILS):Width := 450
self:oDCbBrowser1:GetColumn(#RATE):Width := 90
self:oDCbBrowser1:GetColumn(#UNITS):Width := 90
self:oDCbBrowser1:GetColumn(#RATETYPE):Width := 100
self:oDCbBrowser1:GetColumn(#PONUMBER):Width := 160
self:oDCbBrowser1:GetColumn(#NPC):Width := 500
self:oDCbBrowser1:GetColumn(#JOBFIN):Width := 100
self:oDCbBrowser1:GetColumn(#REGO):Width := 500
self:oDCbBrowser1:GetColumn(#SUBBY):Width := 500
self:oDCbBrowser1:GetColumn(#INVOICED):Width := 100
self:oDCbBrowser1:GetColumn(#INVFILE):Width := 500
self:oDCbBrowser1:GetColumn(#MAPFILE):Width := 500

self:oDCbBrowser1:Refresh()
self:oDCbBrowser1:Recalculate()

self:oDCbBrowser1:SetFocus()
uExtra := self:oDCbBrowser1:Server:FIELDGET(#JOBNUMBER)
return uExtra

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 9:16 am
by lumberjack
Jeff,
BiggyRat wrote:Thank you Johan, but that didn't work. Here's my revised code:
oDCbBrowser1:ColorCondition:Add(oColorCondition, {"Server:JobFin = .t.", oServer, , Brush{Color{COLORRED}}})
Change the above line to:

Code: Select all

oDCbBrowser1:ColorCondition:Add(oColorCondition)

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 9:21 am
by lumberjack
Jeff,
Also I think you need to :Use() before you start painting the bBrowser, then move the color condition to the last statement after you have "painted" your bBrowser.

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 9:47 am
by Karl-Heinz
Hi Jeff,

Following the other thread "JobinFNo" has the order condition "JobFin = .f." so you´ll *never* see a red row if your colorcondition is "Server:JobFin = .t."

What you need is a order without any order condition where the Index expression is "DTos(JobDate)". In this order all JobFin are included , no matter if the JobFin value is true or false. Otherwise you´re colorcondition doesn´t make any sence, because when you switch to the "JobinFYes " order *all* rows are red ;-).

Also, it´s a good idea to give the ColorCondition a readable Textcolor. something like:

oColorCondition := bColorCondition{"Server:JobFin = .t.", oServer, COlor { COLORWHITE }, Brush{Color{COLORRED}}}

regards
Karl-Heinz

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 10:07 am
by BiggyRat
Jeff,
Also I think you need to :Use() before you start painting the bBrowser, then move the color condition to the last statement after you have "painted" your bBrowser.
Again, you've nailed it Johan, thank you very much once again.

Karl-Heinz, thank you also. I hear exactly what you're saying and in fact I use a combobox with 3 options - JobFinYes, JobFinNo and JobDate (all records, and is, as you suggest DTOS(JobDate)) using the 3 indexes (indices???)

bBrowser ColorCondition not working

Posted: Sun Jul 07, 2019 11:08 am
by Karl-Heinz
BiggyRat wrote:.
I hear exactly what you're saying and in fact I use a combobox with 3 options - JobFinYes, JobFinNo and JobDate (all records, and is, as you suggest DTOS(JobDate)) using the 3 indexes (indices???)

Hi Jeff,

I don´t know how your final color presentation should look like ? Which kind of coloring do you want excatly ? Do you want a coloring in each order , or only in the common "Jobdate" order ?

BTW. You can use more than one colorCondition. When you add this the rows are always colored - no matter which order is selected. But the result looks somehow strange :blink:

oColorCondition := bColorCondition{"Server:JobFin = .t.", oServer, Color { COLORWHITE }, Brush{Color{COLORRED}}}
oDCbBrowser1:ColorCondition:Add(oColorCondition)

oColorCondition := bColorCondition{"Server:JobFin = .f.", oServer, Color { COLORWHITE}, Brush{Color{COLORGREEN}}}
oDCbBrowser1:ColorCondition:Add(oColorCondition)

regards
Karl-Heinz