Page 1 of 1

DCBROWSE AND MY PROBLEM

Posted: Sat Jan 04, 2025 4:45 pm
by slobodan1949
Hi Roger,
I can't seem to find a solution. Please help.

How to retrieve the name of the DBF field being edited
from function: AFTER_EDITING(oBrowse)

DCBROWSE oBrowse ALIAS "TEST";
EDIT xbeBRW_ItemSelected ;
ACTION {|| AFTER_EDITING(oBrowse) }

DCBROWSECOL FIELD TEST->ID_NAME CARGO "ID_NAME" PARENT oBrowse

AFTER_EDITING(oBrowse)
oColon := oBrowse:getcolumn(ncol)
_cargo_ := var2char( oColon:CARGO[3] )
msgbox(_cargo_) //--> "ID_NAME"
return nil

Is there ANOTHER more elegant way without using CARGO

I'm confused by THIS, that in the same function it is possible to add a NEW column
to oBrowse by writing the name of the dbf field TEST->FLAG into the oXbpColumn object:

oXbpColumn := XbpColumn():new()
oXbpColumn:dataLink := {|| TEST->FLAG }
oXbpColumn:create()
oBrowse:addColumn( oXbpColumn )

I am convinced that there must be a way to get the DBF field name "FLAG"
without using CARGO. But I can't find it.

Re: DCBROWSE AND MY PROBLEM

Posted: Mon Jan 06, 2025 1:59 am
by SlavkoDam
AFTER_EDITING(oBrowse)
oCol = oBrowse:getcolumn(oBrowse:colPos)
cDataLink = VAR2CHAR(oCol:dataLink)
cFldName = STRTRAN(SUBSTR(cDataLink,AT(">",cDataLink) + 1),"}")
msgbox(cFldName)
return nil

Re: DCBROWSE AND MY PROBLEM

Posted: Mon Jan 06, 2025 11:16 am
by slobodan1949
Hvala Slavko.
Ovo mi je stvarno mnogo trebalo a nisam uspeo da provalim gde leži zec. Zadužio si me.

Re: DCBROWSE AND MY PROBLEM

Posted: Mon Jan 06, 2025 1:18 pm
by rdonnay
Here is another way you can store the field name in the XbpColumn object:

Code: Select all

DCBROWSECOL FIELD CUSTOMER->bill_name HEADER 'Billing Name' WIDTH 25 PARENT oBrowse ;
   EVAL {|o|o:_fieldname := 'BILL_NAME'}

DCREAD GUI EVAL {||(wtf oBrowse:getColumn(1):_fieldName}
You can assign any new variable to the column object. It is stored as a NOIVAR.
I recommend preceding the variable name with an underscore so as not to overwrite any exported variables already defined in the DC_XbpColumn class.

Re: DCBROWSE AND MY PROBLEM

Posted: Thu Jan 09, 2025 12:27 am
by slobodan1949
Thanks Roger,
this method works well.