xBrowse: how to retrieve field names...

User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

xBrowse: how to retrieve field names...

Post 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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: xBrowse: how to retrieve field names...

Post by ADutheil »

Try this:

Code: Select all

MyArrayOfFields := ArrTranspose( oBrw:oMySql:aStructure )[ 1 ] )
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post 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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: xBrowse: how to retrieve field names...

Post 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?
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse: how to retrieve field names...

Post 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
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: xBrowse: how to retrieve field names...

Post 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.
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post 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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: xBrowse: how to retrieve field names...

Post by ADutheil »

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 BCC 5.82 MinGW 4.5.2 MSVS 10
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post 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
 
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: xBrowse: how to retrieve field names...

Post 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 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post 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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Re: xBrowse: how to retrieve field names...

Post 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)
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post by bosibila »

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)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse: how to retrieve field names...

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
bosibila
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Re: xBrowse: how to retrieve field names...

Post 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
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
Post Reply