How do I know the field name in xbrowse:column

Post Reply
User avatar
dutch
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

How do I know the field name in xbrowse:column

Post by dutch »

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

Post by dutch »

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
nageswaragunupudi
Posts: 10701
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 3 times
Contact:

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

Post by nageswaragunupudi »

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

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

Post by dutch »

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
nageswaragunupudi
Posts: 10701
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 3 times
Contact:

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

Post by nageswaragunupudi »

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

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

Post by dutch »

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
nageswaragunupudi
Posts: 10701
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 3 times
Contact:

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

Post by nageswaragunupudi »

oCol:cExpr --> FieldName
Regards

G. N. Rao.
Hyderabad, India
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

Post by dutch »

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

Post by dutch »

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
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

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

Post by Maurizio »

I have these 2 functions

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



Code: Select all | Expand

//-------------------------------------------------------------------------------------------
 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

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

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

Post by dutch »

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

//-------------------------------------------------------------------------------------------
 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

// 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
Maurizio
Posts: 826
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

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

Post by Maurizio »

I use

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

Maurizio
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

Post by dutch »

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
nageswaragunupudi
Posts: 10701
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 3 times
Contact:

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

Post by nageswaragunupudi »

Clarification:
When xbrowse is created with columns clause like this:

Code: Select all | Expand


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

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

Post by dutch »

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


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)
Post Reply