bBrowser bColorCondition using a method?
Posted: Mon May 15, 2023 8:19 pm
In my VO programs I use bColorCondition in some bBrowsers.
One of those browsers show the contents of a dbf called parts (stock info) with a few virtual column showing the price retrieved from another dbf using the partnumber of the stock dbf, added like this for each column, where aList contains the keys for each pricelist:
If I would base a color condition on the main sever (parts), this works fine (coloring alternate rows, this is from the bBrowser help showing an alternate coloring using the main server):
But I can't use the server as I have to lookup a value using the server's partnumber and the current added column from another dbf. I thought that could be solved by using a codeblock which calls a method. It didn't work. Hence I created a simplified version to see where the problem was:
I changed the 1st+2nd line as follows:
Obviously I expect the same alternate coloring, this time done from SomeMethod. But what happens is that the cells (for the added virtual columns) show red for all visible lines, and when I browse further: none. Also the first lines turn black again when I browse back to the top.
Eventually the method should look up the partnumber in the pricelist dbf and return true or false depending on the return result. But if it already doesn't alternate the colors, I apparently should do something else. Can anyone point me in the right direction?
Dick
One of those browsers show the contents of a dbf called parts (stock info) with a few virtual column showing the price retrieved from another dbf using the partnumber of the stock dbf, added like this for each column, where aList contains the keys for each pricelist:
Code: Select all
oColumn := bVirtualFieldColumn{SELF:oDCBrowser,odbsServer,{|oServer,cList| oServer:GetPricelistValue(cList)},#Expression,aLists[ni]}
Code: Select all
local cCond as string
cCond:="Server:RecNo%2=0"
oColorCondition := bColorCondition{cCond,oColumn:Server,Color{COLORRED}}
oColorCondition:SelectedForeground:=Color{COLORRED}
oColumn:ColorCondition:Add(oColorCondition)
I changed the 1st+2nd line as follows:
Code: Select all
local oCond as CodeBlock
oCond:={|oServer|oServer:SomeMethod}
oColorCondition := bColorCondition{oCond,oColumn:Server,Color{COLORRED}}
Code: Select all
METHOD SomeMethod CLASS Parts
LOCAL lRet AS LOGIC
lRet:=SELF:RECNO%2=0 // SHould return true (and color red) for every second record of parts.dbf
Return lRet
Eventually the method should look up the partnumber in the pricelist dbf and return true or false depending on the return result. But if it already doesn't alternate the colors, I apparently should do something else. Can anyone point me in the right direction?
Dick