How to assign a value to a bBrowser VirtualColumn field?

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

How to assign a value to a bBrowser VirtualColumn field?

Post 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
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to assign a value to a bBrowser VirtualColumn field?

Post by wriedmann »

Hi Dick,
you can change the values in the underlying server and send Notify messages.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Joachim Bieler
Posts: 36
Joined: Mon Aug 19, 2019 1:51 pm

How to assign a value to a bBrowser VirtualColumn field?

Post 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
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to assign a value to a bBrowser VirtualColumn field?

Post 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
Post Reply