Page 1 of 2
xBrowse: how to retrieve field names...
Posted: Sun Sep 29, 2013 8:50 pm
by bosibila
Can I with oBrw:aCols[ x ]... class tXbrowse (FWH 11.07) retrieve field names, like I retrieve header (oBrw:aCols
:aHeaders)?
I work with tDolphin and MySQL. Here is small example.
I try to get "first","last","city" fields in array, but without success.
Code: Select all
aadd( aFields, "first" ); aadd( aHead, "Head 1" ); aadd( aFormat, "" )
aadd( aFields, "last" ); aadd( aHead, "Head 2" ); aadd( aFormat, "" )
aadd( aFields, "city" ); aadd( aHead, "Head 3" ); aadd( aFormat, "" )
@ 0,0 XBROWSE oBrw OF oWnd OBJECT oQry COLUMNS aFields HEADERS aHead LINES CELL FASTEDIT
//----------------------------------------------------------------------------------------
oBrw:CreateFromCode()
oWnd:oClient = oBrw
Best regards
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 12:11 am
by ADutheil
Try this:
Code: Select all
MyArrayOfFields := ArrTranspose( oBrw:oMySql:aStructure )[ 1 ] )
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 5:45 am
by bosibila
I try this this command earlier,but this give me all fields from database table, not those that I choose for my xBrowse.
Thanks
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 10:36 am
by ADutheil
I don´t understand what you are trying to do. The fields already are in the array you used to build the browse. Field in column n is aFields[ n ] or am I missing something?
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 2:03 pm
by Rick Lipkin
Boris
This should work if you want to get the value of a header from a clicked cell ..
Code: Select all
cText := oLbxA:SelectedCol():cHeader
Rick Lipkin
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 3:11 pm
by Gale FORd
I put the actual field name in :cargo when i need to know later.
The header does not contain the field name and data is generally a code block.
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 4:44 pm
by bosibila
I use two ways to add fields/headers/format array for xBrowse, something like this:
Code: Select all
aadd( aFields, "sifr" ); aadd( aHead, "Šifra" ); aadd( aFormat, "@!" )
aadd( aFields, "bar" ); aadd( aHead, "Bar-kod" ); aadd( aFormat, "@!" )
aadd( aFields, "naziv" ); aadd( aHead, "Naziv robe" ); aadd( aFormat, "@!" )
aadd( aFields, "mc" ); aadd( aHead, "Mc" ); aadd( aFormat, "@Z 9999,999.99" )
...
ADD FIELDS TO XBROWSE oBrw AT 01 DATA storno HEADER "Storno"
ADD FIELDS TO XBROWSE oBrw AT 02 DATA matc->grupa+' '+grup->konto HEADER "Grupa/Konto"
ADD FIELDS TO XBROWSE oBrw AT 05 DATA matc->naziv HEADER "Naziv robe"
...
? "result: -> ", oBrw:aCols[2]:aHeaders (result: -> Grupa/Konto)
In one moment I saw solution in "cargo" method, but I think, if there is way to retrieve header (like this example), must be a way to retrieve field name.
Best regards
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 2:20 am
by ADutheil
Has the command ADD FIELDS TO XBROWSE been introduced after FWH 13.04? I cant find it in my ch files.
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 4:59 am
by bosibila
I have version 11.07 and this command works fine
Code: Select all
ADD FIELDS TO XBROWSE oBrw AT 01 DATA (if( empty(oQry:jsf),.f.,.t.)) HEADER "I"
oCol:=oBrw:aCols[ 1 ]
oCol:SetCheck( { "ON", "OFF" } )
oCol:cSortOrder := nil
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 8:27 am
by Antonio Linares
Boris,
Do you mean to retrieve the column DATA description ?
ADD FIELDS TO XBROWSE oBrw AT 02 DATA matc->grupa+' '+grup->konto HEADER "Grupa/Konto"
from the above it would be:
"matc->grupa+' '+grup->konto"
is this what you mean ?
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 9:57 am
by bosibila
Antonio,
thanks for your time. Yes, char/strigs what are in array for xBrw field name (in above examlpe aFields array { "sifr","bar" ,"naziv","mc","storno","matc->grupa+' '+grup->konto" } or { "oQry:sifr","oQry:bar" ,"oQry:naziv" } ). I have some idea ho to solve this, but if exist something like ... oBrw:aCols[count]:aField ..., it will simplify my job.
Best regards
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 1:51 pm
by Gale FORd
Using your example
ADD FIELDS TO XBROWSE oBrw AT 01 DATA storno HEADER "Storno"
ADD FIELDS TO XBROWSE oBrw AT 02 DATA matc->grupa+' '+grup->konto HEADER "Grupa/Konto"
ADD FIELDS TO XBROWSE oBrw AT 05 DATA matc->naziv HEADER "Naziv robe"
oBrw:aCols[1]:cargo := [storno]
oBrw:aCols[2]:cargo := [Grupa/Konto]
oBrw:aCols[3]:cargo := [naziv]
Then later you can retrieve the char value
? "result: -> ", oBrw:aCols[2]:cargo (result: -> Grupa/Konto)
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 3:40 pm
by bosibila
Gale,
I alredy try your code with my aplication. Works fine.
Thanks
Re: xBrowse: how to retrieve field names...
Posted: Wed Oct 02, 2013 4:08 am
by nageswaragunupudi
Mr Bosibila
I do not remember from which version we introduced this, but now oCol:cExpr returns the field name for you.
Please check if this DATA ( oCol:cExpr ) is in your version.
Re: xBrowse: how to retrieve field names...
Posted: Wed Oct 02, 2013 7:47 am
by bosibila
Mr Rao,
yes it is in my version. I try example with for/loop and :cHeader returns legal string array but :cExpr return "nil"
Code: Select all
for i=1 to len( oBrw:aCols )
oCol:=oBrw:aCols[ i ]
var1:=oCol:cExpr // returns"nil"
var2:=oCol:cHeader // returns string array with headers...
next
I will tray to check why...
Best regards