From: Bill Tillick on
Hello,
I have recently upgraded to VO2.8, downloaded and tested bBrowser1.4
in the past week, and today purchased and installed bBrowser3.

I have added a last column to a bBrowse that is not linked to the
server and contains just a logical value (true/false).
The ViewValueAs for that field is #CHECKBOX In bB1.4 the column
showed Checkboxes, in bB3 the Checkboxes are missing. What have I done
wrong in the code below:-

oColumn := bDataColumn{ self:oDCbBrowse, self:oDCbBrowse:Server, {|
oWin| oWin:IsTagged()} , #Expression } // #2 param was
self:server, #3 was {|x| x:IsTagged }
oColumn:HyperLabel := HyperLabel{#SELECTION}
oColumn:Width := 25
oColumn:Caption := "Del"
oColumn:ValType := "L"
oColumn:ViewValueAs := #CHECKBOX
oColumn:CaptionView := bViewStyle{}
oColumn:CaptionView:Background:= Brush{Color{COLORRED}}
self:oDCbBrowse:AddColumn( oColumn )
self:oDCbBrowse:OpenColumn(oColumn )

Also, neither version shows the checkbox tick (although the 1.4
version did intermittently for a while; not sure what I did to lose
it!!)
My toggling method returns true/false depending on the previous state
being false/true.

Help please.
Regards,
Bill
From: Geoff Schaller on
Bill,

When you are trying to debug such things, remove all the fluff first and
just get the basic commands in play. Once these work, add the cosmetics.
Let me distil down your code:

oColumn := bDataColumn{ self:oDCbBrowse, self:oDCbBrowse:Server, {|oWin|
oWin:IsTagged()} , #Expression }
self:oDCbBrowse:AddColumn( oColumn )
self:oDCbBrowse:OpenColumn(oColumn )

This is the important code. Now, reading the bBrowser help (which I am
sure you did), you will know that the server expressed in the
constructor - self:odcbBrowse:Server - will be passed as the first
parameter to the expression code block. You called it oWin but of course
it could be anything. So the code block executes the method IsTagged()
on that server. With me so far?

If that method exists then all will be well and your default column will
show. Most of those properties are better set in the WED rather than
deliberately but it makes no difference. That should all be fine. Now
let's say IsTagged really was a method on the local window. Now you need
a 2nd (and/or 3rd, 4th or 5th) parameter to pass to the code block.
Reading the manual again, here is how I would send the current browser
server to a method on the current window:

oColumn := bDataColumn{ oBrowser, oServer, {|oDBF, oWin, P2, P3...|
oWin:IsTagged(oDBF) .or. (P2 .and. P3)} , #Expression, SELF, P2, P3... }

oDBF = oServer
oWin = SELF (the local window)
P2 = whatever...

You see how you can pass up to 4 more parameters to the code block and
where they live in the constructor. As long as the code block can
consume them, you can send them.

Cheers,

Geoff



"Bill Tillick" <wtillick(a)gmail.com> wrote in message
news:593fe278-2a96-492b-8fb6-f6ac8a0ebcff(a)r5g2000prf.googlegroups.com:

> Hello,
> I have recently upgraded to VO2.8, downloaded and tested bBrowser1.4
> in the past week, and today purchased and installed bBrowser3.
>
> I have added a last column to a bBrowse that is not linked to the
> server and contains just a logical value (true/false).
> The ViewValueAs for that field is #CHECKBOX In bB1.4 the column
> showed Checkboxes, in bB3 the Checkboxes are missing. What have I done
> wrong in the code below:-
>
> oColumn := bDataColumn{ self:oDCbBrowse, self:oDCbBrowse:Server, {|
> oWin| oWin:IsTagged()} , #Expression } // #2 param was
> self:server, #3 was {|x| x:IsTagged }
> oColumn:HyperLabel := HyperLabel{#SELECTION}
> oColumn:Width := 25
> oColumn:Caption := "Del"
> oColumn:ValType := "L"
> oColumn:ViewValueAs := #CHECKBOX
> oColumn:CaptionView := bViewStyle{}
> oColumn:CaptionView:Background:= Brush{Color{COLORRED}}
> self:oDCbBrowse:AddColumn( oColumn )
> self:oDCbBrowse:OpenColumn(oColumn )
>
> Also, neither version shows the checkbox tick (although the 1.4
> version did intermittently for a while; not sure what I did to lose
> it!!)
> My toggling method returns true/false depending on the previous state
> being false/true.
>
> Help please.
> Regards,
> Bill

From: Bill Tillick on
Geoff,
Thanks for that.
My extra column is NOT linked to the server, I want it to be just a
checkbox that the user can select/deselect for a row.

I didn't previously understand the parameters in bDataColumn
initialise, but think I have got that sorted now thanks to you; I was
missing SELF as the first parameter. So now the checkboxes are
showing.

The self:IsTagged method now returns FALSE, so that gets the column
established initially as all empty checkboxes. Is there any way to
replace the {|oServer, oWin| oWin:IsTagged()} codeblock with the
equivalent of FALSE so that the method doesn't need to be called for
each record? (slightly faster??)

Now, how do I cause an individual checkbox to toggle when the user
clicks (or doubleclicks) on it? I know how to address the current row,
but how do I address the particular checkbox field in that row. I
can't see in the Help that something like
self:oDCbBrowse:CurrentRow:MyColumn is valid?
Should I use bBrowser:CellClick() and access the ControlEvent?

I would also like to retain the ability to use doubleclick to call an
update window for a row. (I have the row option set to #LINE now.)
At this stage I suspect my best option would be to use doubleclick for
both actions and have a pushbutton to switch between toggle or update?

Thanks again,
Bill




From: Stephen Quinn on
Bill

> The self:IsTagged method now returns FALSE, so that gets the column
> established initially as all empty checkboxes. Is there any way to
> replace the {|oServer, oWin| oWin:IsTagged()} codeblock with the
> equivalent of FALSE so that the method doesn't need to be called for
> each record? (slightly faster??)

One way is to supply an empty array to store the states of each row/

PROTECT aisTagged AS ARRAY

SELF:aisTagged := arrayNew( self:oServer:Reccount )
AFill( SELF:aisTagged, FALSE )

METHOD isTagged( nRecNo ) CLASS MyWindow

IF nRecNo <= ALen( SELF:aisTagged ) // Toggle the checkbox
SELF:aisTagged[ nRecNo ] := ! SELF:aisTagged[ nRecNo ]
ENDIF

RETURN SELF:aisTagged[ nRecNo ]

Use CellClick()/CellBoubleClick() to call the isTagged() method or just use
the #EXPRESSION syntax

CYA
Steve


From: Geoff Schaller on
Bill.

Firstly, to toggle data you need to make the browser editable and
especially that column editable. Then you can edit values.

But you are using an expression column. This is ONLY ever a readonly
thing. If you need to persist a value (for later use) please see the
bVirtualFieldColumn, which I helped create for Joachim. It will persist
values given to rows in an array rather like that suggested by Steve but
you don't have to manage this yourself, it is already done by Joachim.

In fact there is even a special column class called bCheckColumn. It has
a bunch of useful methods to get an array of checked rows/recnos etc.
Joachim has even supplied a sample to show it in use.

Cheers.

Geoff



"Bill Tillick" <wtillick(a)gmail.com> wrote in message
news:d88c7c6e-ff5c-4ec1-9351-edbbdb056124(a)n20g2000prh.googlegroups.com:

> Geoff,
> Thanks for that.
> My extra column is NOT linked to the server, I want it to be just a
> checkbox that the user can select/deselect for a row.
>
> I didn't previously understand the parameters in bDataColumn
> initialise, but think I have got that sorted now thanks to you; I was
> missing SELF as the first parameter. So now the checkboxes are
> showing.
>
> The self:IsTagged method now returns FALSE, so that gets the column
> established initially as all empty checkboxes. Is there any way to
> replace the {|oServer, oWin| oWin:IsTagged()} codeblock with the
> equivalent of FALSE so that the method doesn't need to be called for
> each record? (slightly faster??)
>
> Now, how do I cause an individual checkbox to toggle when the user
> clicks (or doubleclicks) on it? I know how to address the current row,
> but how do I address the particular checkbox field in that row. I
> can't see in the Help that something like
> self:oDCbBrowse:CurrentRow:MyColumn is valid?
> Should I use bBrowser:CellClick() and access the ControlEvent?
>
> I would also like to retain the ability to use doubleclick to call an
> update window for a row. (I have the row option set to #LINE now.)
> At this stage I suspect my best option would be to use doubleclick for
> both actions and have a pushbutton to switch between toggle or update?
>
> Thanks again,
> Bill