FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse: how to retrieve field names...
Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
xBrowse: how to retrieve field names...
Posted: Sun Sep 29, 2013 08:50 PM
Can I with oBrw:aCols[ x ]... class tXbrowse (FWH 11.07) retrieve field names, like I retrieve header (oBrw:aCols[i]: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 (fw): Select all Collapse
    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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 12:11 AM
Try this:

Code (fw): Select all Collapse
MyArrayOfFields := ArrTranspose( oBrw:oMySql:aStructure )[ 1 ] )
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 05:45 AM

I try this this command earlier,but this give me all fields from database table, not those that I choose for my xBrowse.

Thanks

Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 10:36 AM

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?

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 02:03 PM
Boris

This should work if you want to get the value of a header from a clicked cell ..
Code (fw): Select all Collapse
cText := oLbxA:SelectedCol():cHeader


Rick Lipkin
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 03:11 PM

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.

Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Mon Sep 30, 2013 04:44 PM
I use two ways to add fields/headers/format array for xBrowse, something like this:
Code (fw): Select all Collapse
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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 02:20 AM

Has the command ADD FIELDS TO XBROWSE been introduced after FWH 13.04? I cant find it in my ch files.

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 04:59 AM
I have version 11.07 and this command works fine
Code (fw): Select all Collapse
         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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 08:27 AM

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 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 09:57 AM
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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 01:51 PM

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)

Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Tue Oct 01, 2013 03:40 PM

Gale,

I alredy try your code with my aplication. Works fine.

Thanks

Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse: how to retrieve field names...
Posted: Wed Oct 02, 2013 04:08 AM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 53
Joined: Wed Aug 06, 2008 05:27 PM
Re: xBrowse: how to retrieve field names...
Posted: Wed Oct 02, 2013 07:47 AM
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 (fw): Select all Collapse
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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)