xBrowse: how to retrieve field names...

xBrowse: how to retrieve field names...

Postby bosibila » Sun Sep 29, 2013 8: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: Select all  Expand view
   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)
User avatar
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

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

Postby ADutheil » Mon Sep 30, 2013 12:11 am

Try this:

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

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

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

Postby bosibila » Mon Sep 30, 2013 5: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)
User avatar
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

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

Postby ADutheil » 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
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

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

Postby Rick Lipkin » Mon Sep 30, 2013 2:03 pm

Boris

This should work if you want to get the value of a header from a clicked cell ..
Code: Select all  Expand view

cText := oLbxA:SelectedCol():cHeader
 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

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

Postby Gale FORd » Mon Sep 30, 2013 3: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.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

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

Postby bosibila » Mon Sep 30, 2013 4:44 pm

I use two ways to add fields/headers/format array for xBrowse, something like this:
Code: Select all  Expand view

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

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

Postby ADutheil » Tue Oct 01, 2013 2: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
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

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

Postby bosibila » Tue Oct 01, 2013 4:59 am

I have version 11.07 and this command works fine
Code: Select all  Expand view
        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
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

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

Postby Antonio Linares » Tue Oct 01, 2013 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41404
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby bosibila » Tue Oct 01, 2013 9: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)
User avatar
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

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

Postby Gale FORd » Tue Oct 01, 2013 1: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)
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

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

Postby bosibila » Tue Oct 01, 2013 3: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)
User avatar
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

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

Postby nageswaragunupudi » Wed Oct 02, 2013 4: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
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

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

Postby bosibila » Wed Oct 02, 2013 7: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: Select all  Expand view
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)
User avatar
bosibila
 
Posts: 53
Joined: Wed Aug 06, 2008 5:27 pm
Location: Osijek, Croatia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests