How do I know the field name in xbrowse:column

How do I know the field name in xbrowse:column

Postby dutch » Wed Dec 15, 2021 9: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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby dutch » 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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Sun Dec 19, 2021 6: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How do I know the field name in xbrowse:column

Postby dutch » Mon Dec 20, 2021 2: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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Mon Dec 20, 2021 3: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How do I know the field name in xbrowse:column

Postby dutch » Wed Dec 22, 2021 5: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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Thu Dec 23, 2021 1:55 am

oCol:cExpr --> FieldName
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How do I know the field name in xbrowse:column

Postby dutch » Thu Dec 23, 2021 4:17 pm

Dear Master,

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

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby dutch » Mon Jan 24, 2022 6: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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby Maurizio » Mon Jan 24, 2022 8:07 am

I have these 2 functions

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



Code: Select all  Expand view  RUN
//-------------------------------------------------------------------------------------------
 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( ::oRsRig:Fields( "PADRE" ):Value ==2,.F.,.T. )}


Code: Select all  Expand view  RUN
// 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
User avatar
Maurizio
 
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm

Re: How do I know the field name in xbrowse:column

Postby dutch » Mon Jan 24, 2022 9: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: Select all  Expand view  RUN
//-------------------------------------------------------------------------------------------
 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( ::oRsRig:Fields( "PADRE" ):Value ==2,.F.,.T. )}


Code: Select all  Expand view  RUN
// 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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby Maurizio » Mon Jan 24, 2022 9:52 am

I use

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

Maurizio
User avatar
Maurizio
 
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm

Re: How do I know the field name in xbrowse:column

Postby dutch » Thu Jan 27, 2022 9:51 am

Dear Master Rao and Maurizio,

It works now.

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

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Mon Jan 31, 2022 3:49 pm

Clarification:
When xbrowse is created with columns clause like this:
Code: Select all  Expand view  RUN

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

Re: How do I know the field name in xbrowse:column

Postby dutch » Tue Feb 01, 2022 1: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: Select all  Expand view  RUN

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 19.01 / 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)
User avatar
dutch
 
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests