FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How do I know the field name in xbrowse:column
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How do I know the field name in xbrowse:column
Posted: Wed Dec 15, 2021 09:47 AM

I use XBROWSE with MySql. I would like to know the field name in column. Because the user can swap or hide the column.
for example
=============
XBROWSE COLUMN 'room', 'name', 'mobile'
if the user swap 'name' to 1st column, then when the user dblclick on 1st column. How do I know that it is field name 'name'?

Thank you in advance

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Sun Dec 19, 2021 11:01 AM
Master Rao,

Is it possible, because when the user modify column such as swap or hide. It will effect, if that column (number) has action.
dutch wrote:I use XBROWSE with MySql. I would like to know the field name in column. Because the user can swap or hide the column.
for example
=============
XBROWSE COLUMN 'room', 'name', 'mobile'
if the user swap 'name' to 1st column, then when the user dblclick on 1st column. How do I know that it is field name 'name'?

Thank you in advance
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How do I know the field name in xbrowse:column
Posted: Sun Dec 19, 2021 06:06 PM

All actions are attached to the column object and move with the column object.

For example:
When you define the browse, "room" is the first column.
You defined some action oBrw:aCols[ 1 ]:bLDClickData := {|| roomaction() }
Wherever the user moves / swaps this column, if the user clicks on the "room" column, the same action is taken.

All the datas/codeblocks assigned to a column pertain that column object, not to the visible serial number of the column.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Mon Dec 20, 2021 02:21 AM
Dear Master Rao,

Thank you, it works fine for oBrw:aCols[ 1 ]:bLDClickData but I cannot find for ::bLClicked (Left single click) in TXBrwColumn.

nageswaragunupudi wrote:All actions are attached to the column object and move with the column object.

For example:
When you define the browse, "room" is the first column.
You defined some action oBrw:aCols[ 1 ]:bLDClickData := {|| roomaction() }
Wherever the user moves / swaps this column, if the user clicks on the "room" column, the same action is taken.

All the datas/codeblocks assigned to a column pertain that column object, not to the visible serial number of the column.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How do I know the field name in xbrowse:column
Posted: Mon Dec 20, 2021 03:05 AM

There is no bLClicked data for TXBrwColumn.
The intention of the original authors of the XBrowse is not to use single-click for any action, because single-click is used for navigation in the browse. If an action is assigned to single click, there would be confusion between navigation and which cell to act upon.

Still if you want to assign action to single click, assign the action to oBrw:bRClicked and you can ascertain the active column with oBrw:SelectedCol()

Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Wed Dec 22, 2021 05:15 PM
Dear Master,

Thank you so much, I got it.
nageswaragunupudi wrote:There is no bLClicked data for TXBrwColumn.
The intention of the original authors of the XBrowse is not to use single-click for any action, because single-click is used for navigation in the browse. If an action is assigned to single click, there would be confusion between navigation and which cell to act upon.

Still if you want to assign action to single click, assign the action to oBrw:bRClicked and you can ascertain the active column with oBrw:SelectedCol()
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How do I know the field name in xbrowse:column
Posted: Thu Dec 23, 2021 01:55 AM

oCol:cExpr --> FieldName

Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Thu Dec 23, 2021 04:17 PM
Dear Master,

It shows nothing (empty).
nageswaragunupudi wrote:oCol:cExpr --> FieldName
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Mon Jan 24, 2022 06:26 AM
Dear Mr.Rao,

oCol:cExpr is define columns name at first start. When hide some column, oCol:cExpr will show wrong fieldname.
nageswaragunupudi wrote:oCol:cExpr --> FieldName
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: How do I know the field name in xbrowse:column
Posted: Mon Jan 24, 2022 08:07 AM
I have these 2 functions

if XBrowse_FindCol(oBrw,'COST') > 0
oBrw:DelCol( XBrowse_FindCol(oBrw,'COST'))
ENDIF



Code (fw): Select all Collapse
//-------------------------------------------------------------------------------------------
 Function XBrowse_FindCol(o,cField)
 Local n := 1 // := ascan(o:aCols,{|x| upper(x:cExpr)== upper(cField)})
 local nH := 0
 FOR n := 1 to len(o:aCols)
    IF o:aCols[n]:lHide
       nH ++
    ENDIF    
 
    IF   HB_IsString(o:aCols[n]:cExpr)  .and. UPPER(o:aCols[n]:cExpr) == UPPER(cField)
       Return n - nH 
    ENDIF    
 next 
  
 Return 0


and I added in xBrowse.prg the method fcol

oBrw:fCol('COST'):bEditWhen := {||iif( ::Fields( "PADRE" ):Value ==2,.F.,.T. )}


Code (fw): Select all Collapse
// my_modi
METHOD fCol(cField) CLASS TXBrowse
Local n := 0 
 FOR n := 1 to len(::aCols)
    IF HB_IsString(::aCols[n]:cExpr)  .and. UPPER(::aCols[n]:cExpr) == UPPER(cField)
       exit 
    ENDIF    
 next 
return If( n > 0, ::aCols[ n ], nil )


Maurizio
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Mon Jan 24, 2022 09:19 AM
Dear Maurizio,

Thank you, this case has solved hide columns scenario.
Another scenario is swap column, I'm still got problem. I cannot check the current field on ::nColSel, if the user swap column.
Maurizio wrote:I have these 2 functions

if XBrowse_FindCol(oBrw,'COST') > 0
oBrw:DelCol( XBrowse_FindCol(oBrw,'COST'))
ENDIF



Code (fw): Select all Collapse
//-------------------------------------------------------------------------------------------
 Function XBrowse_FindCol(o,cField)
 Local n := 1 // := ascan(o:aCols,{|x| upper(x:cExpr)== upper(cField)})
 local nH := 0
 FOR n := 1 to len(o:aCols)
    IF o:aCols[n]:lHide
       nH ++
    ENDIF    
 
    IF   HB_IsString(o:aCols[n]:cExpr)  .and. UPPER(o:aCols[n]:cExpr) == UPPER(cField)
       Return n - nH 
    ENDIF    
 next 
  
 Return 0


and I added in xBrowse.prg the method fcol

oBrw:fCol('COST'):bEditWhen := {||iif( ::Fields( "PADRE" ):Value ==2,.F.,.T. )}


Code (fw): Select all Collapse
// my_modi
METHOD fCol(cField) CLASS TXBrowse
Local n := 0 
 FOR n := 1 to len(::aCols)
    IF HB_IsString(::aCols[n]:cExpr)  .and. UPPER(::aCols[n]:cExpr) == UPPER(cField)
       exit 
    ENDIF    
 next 
return If( n > 0, ::aCols[ n ], nil )


Maurizio
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: How do I know the field name in xbrowse:column
Posted: Mon Jan 24, 2022 09:52 AM

I use

cField := oBrw:aCols[oBrw:nColSel]:cExpr

Maurizio

Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Thu Jan 27, 2022 09:51 AM
Dear Master Rao and Maurizio,

It works now.

Thanks both of you.
nageswaragunupudi wrote:oCol:cExpr --> FieldName
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How do I know the field name in xbrowse:column
Posted: Mon Jan 31, 2022 03:49 PM
Clarification:
When xbrowse is created with columns clause like this:
Code (fw): Select all Collapse
COLUMNS "ITEM","UPPER(NAME)","QTY","PRICE","QTY * PRICE" ;
HEADERS "Item", "Name", "Quantity", "Rate", "Amount" ;

The expressions listed in COLUMNS clause are stored in each oCol:cExpr.
So, oCol:cExpr need not always contain the field name, but actually the expression used in the COLUMNS clause.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I know the field name in xbrowse:column
Posted: Tue Feb 01, 2022 01:50 AM
Dear Master,

I got it, it works fine now. But the hidden is still a bit complicated clarify.
nageswaragunupudi wrote:Clarification:
When xbrowse is created with columns clause like this:
Code (fw): Select all Collapse
COLUMNS "ITEM","UPPER(NAME)","QTY","PRICE","QTY * PRICE" ;
HEADERS "Item", "Name", "Quantity", "Rate", "Amount" ;

The expressions listed in COLUMNS clause are stored in each oCol:cExpr.
So, oCol:cExpr need not always contain the field name, but actually the expression used in the COLUMNS clause.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)