Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

bBrowser bColorCondition using a method? 15 May 2023 22:19 #26327

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1662
  • 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:
    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):
    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:
    local oCond as CodeBlock
    oCond:={|oServer|oServer:SomeMethod}
    oColorCondition := bColorCondition{oCond,oColumn:Server,Color{COLORRED}}
    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

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    bBrowser bColorCondition using a method? 16 May 2023 11:14 #26330

    • g.bunzel@domonet.de's Avatar


  • Posts: 90
  • 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

    Please Log in or Create an account to join the conversation.

    bBrowser bColorCondition using a method? 17 May 2023 14:46 #26354

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1662
  • 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

    Please Log in or Create an account to join the conversation.

    bBrowser bColorCondition using a method? 17 May 2023 15:28 #26355

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • 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

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    bBrowser bColorCondition using a method? 17 May 2023 17:03 #26362

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1662
  • Hello Wolfgang,

    In the meantime I found out Gerhard & you are both right. Like this:
    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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1