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?
How to assign a value to a bBrowser VirtualColumn field?
Hi Dick,
you can change the values in the underlying server and send Notify messages.
Wolfgang
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
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
- Joachim Bieler
- Posts: 37
- Joined: Mon Aug 19, 2019 1:51 pm
- Location: Germany
How to assign a value to a bBrowser VirtualColumn field?
Hi Dick,
you can change the column value of the current record with the following code:
If values in several records need to be changed, then I would use the following code:
For more information see also bVirtualFieldColumn:DataPut()
Regards
Joachim
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
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)
Regards
Joachim
How to assign a value to a bBrowser VirtualColumn field?
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
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