xsharp.eu • How to assign a value to a bBrowser VirtualColumn field?
Page 1 of 1

How to assign a value to a bBrowser VirtualColumn field?

Posted: Fri Oct 09, 2020 4:22 pm
by ic2
In a VO bBrowser I have a VirtualColumn, defined in the browser as follows:

oVirtualColumn := bVirtualFieldColumn {SELF:odcbBrowser, oDB, {|oServer| 0}, #EXPRESSION}
oVirtualColumn:FieldSpec := FieldSpec {HyperLabel {#SPLITCOLUMN, "Split"}, "N", 8, 0}
oVirtualColumn:CaptionView := bViewStyle { , , BALIGN_CENTER}
oVirtualColumn:SuspendEmptyValues := FALSE
oVirtualColumn:PropertyPut(#EmptyValueCondition, {|x| x=NIL})bBrowser update
oVirtualColumn:Width := 40
SELF:odcbBrowser:AddColumn(oVirtualColumn)
SELF:odcbBrowser:OpenColumn(oVirtualColumn)
oVirtualColumn:Editable := TRUE

In a CellEdit method I arrange that the user can enter values straight from the bBrowser (while the other, DBF bound, fields can not be edited directly).

This works fine. But now I had the request to assign a value to a selection of bBrowser rows programmatically and I found that I couldn't figure out how that should be done.

A normal fieldput doesn't work, and :

oColumn:=SELF:oDCbBrowser:GetColumn(#SPLITCOLUMN)
auFieldData:=oColumn:DataList

won't work either because auFieldData collects only manually changed values so I can not insert the value in one of the underlying arrays.

Does anyone have a solution for this?

Dick

How to assign a value to a bBrowser VirtualColumn field?

Posted: Sat Oct 10, 2020 4:44 am
by wriedmann
Hi Dick,
you can change the values in the underlying server and send Notify messages.
Wolfgang

How to assign a value to a bBrowser VirtualColumn field?

Posted: Sun Oct 11, 2020 1:10 pm
by Joachim Bieler
Hi Dick,

you can change the column value of the current record with the following code:

Code: Select all

oColumn := self:oDCBrowser:GetColumn(#YourColumnName)
oColumn:Value += 1
If values in several records need to be changed, then I would use the following code:

Code: Select all

oColumn := self:oDCBrowser:GetColumn(#YourColumnName)
odbsServer := self:oDCBrowser:Server
odbsServer:SuspendNotification()	
iRecNo := odbsServer:RecNo

oColumn:DataPut(odbsServer:RecNo, 1)
odbsServer:Skip(1)

oColumn:DataPut(odbsServer:RecNo, 2)
odbsServer:Skip(1)

oColumn:DataPut(odbsServer:RecNo, 3)

odbsServer:RecNo := iRecNo
odbsServer:ResetNotification()
odbsServer:Notify(NOTIFYFILECHANGE)	
For more information see also bVirtualFieldColumn:DataPut()

Regards
Joachim

How to assign a value to a bBrowser VirtualColumn field?

Posted: Mon Oct 12, 2020 3:36 pm
by ic2
Hello Joachim,

Thanks for the quick reply! This works very well; I have a loop going through the actually user selected line so I changed that part to:

nRecNo:=odbsServer:RecNo
FOR ni:=1 UPTO ALen(aSel)
oColumn:DataPut(odbsServer:RecNo,nAmt)
odbsServer:goto(aSel[ni])
NEXT
where array aSel contains the selected bBrowser recordnumbers.

@Wolfgang: this is actually a virtual field because it is not present in the database. Users can enter an amount there to split order lines into 1 line with the entered amount and 1 line with the remaining amount, and they wanted to be able to assign the same value to a larger selection of lines.

Dick