bBrowser bColorCondition using a method?

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

bBrowser bColorCondition using a method?

Post by ic2 »

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:

Code: Select all

oColumn := bVirtualFieldColumn{SELF:oDCBrowser,odbsServer,{|oServer,cList| oServer:GetPricelistValue(cList)},#Expression,aLists[ni]}
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):

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

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
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
g.bunzel@domonet.de
Posts: 97
Joined: Tue Mar 01, 2016 11:50 am
Location: Germany

bBrowser bColorCondition using a method?

Post by g.bunzel@domonet.de »

Dick,

that should work:

METHOD ....... CLASS MyWindowWithbBrowser
...
oColorCondition := bColorCondition{"Server:SomeMethod()", SELF, Color{COLORRED}}
oColumn:ColorCondition:Add(oColorCondition)
...


METHOD SomeMethod () AS LOGIC PASCAL CLASS MyWindowWithbBrowser
LOCAL lRet AS LOGIC
lRet:=SELF:odbsPARTS:RECNO%2=0 // Should return true (and color red) for every second record of parts.dbf
Return lRet

HTH

Gerhard Bunzel
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

bBrowser bColorCondition using a method?

Post by ic2 »

Hello Gerhard,

Thanks for your reply.

It can't work I'd say as you write it as the first parameter of the bColorCondition calls Server:SomeMethod() while your idea is that this SomeMethod must be moved to the class of the calling window.

I can not change the 1st parameter to just SomeMethod or Self:Somemethod (and change the class of SomeMethod to that of the window) because in that case SomeMethod simply isn't called once.

It is called when from the class of the main server, but as written, the calls seem erratic and the coloring is not applied as it should: only all lines the first screen (and only until browsing away and back) instead of every 2nd line.

The problem with conditions like these is that they are hard to test as they just don't appear in a loop or something you can debug. You just hope it is is called and when it's called and it doesn't work there is no way to find out why not.

Should you have another suggestion to get this done, I would be very interested.

Dick
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

bBrowser bColorCondition using a method?

Post by wriedmann »

Hi Dick,
"Server:SomeMethod()" refers to the server that is bound to the bBrowser control, not to the owner window.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

bBrowser bColorCondition using a method?

Post by ic2 »

Hello Wolfgang,

In the meantime I found out Gerhard & you are both right. Like this:

Code: Select all

bColorCondition{"Server:SomeMethod(Column, Row)",SELF,Color{COLORRED},Brush{Color{COLORRED}}}


In the method (of the used window class) I can get the column & row of the browser. But what I tried is pass a local variable. That still works but the strange thing is that as soon as I actually used it (to search in the other database), the whole method wasn't called at all and the bBrowser shows completely (but obviously without colors).

I would expect a seek but not found, an incorrect value of the parameter or maybe a run time error. No idea why it is called unless I actually use a variable - but hence my confusion.

Thanks a lot for your answer(s), I'd say I should be able to get the right values colored now!

Dick
Post Reply