Know the Column number clicked on the TXBrowse Header

Post Reply
INFORMAISVRB
Posts: 51
Joined: Tue Mar 23, 2010 12:53 pm
Contact:

Know the Column number clicked on the TXBrowse Header

Post by INFORMAISVRB »

Hello

Is there any way to know which column (header was clicked by the User)

Image

Example of clicking the header "fantasy" would be number 3


thank you all friend
User avatar
Antonio Linares
Site Admin
Posts: 42483
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Know the Column number clicked on the TXBrowse Header

Post by Antonio Linares »

Here you have an example:

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local oBrowser

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol | MsgInfo( oBrowser:MouseColPos( nMCol ) ) } } ) )

return nil
Basically all you have to do is set the codeblock bLClickHeader for each column of the browser
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42483
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Know the Column number clicked on the TXBrowse Header

Post by Antonio Linares »

This version works also when the browse is scrolled:

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local oBrowser, oColumn

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol, nFlags, oCol | ;
      oColumn := oCol, MsgInfo( AScan( oBrowser:aCols, { | o | o == oColumn } ) ) } } ) )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42483
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Know the Column number clicked on the TXBrowse Header

Post by Antonio Linares »

From Mr. Rao:
To know the column number when created.
oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nCreationOrder ) }
To know the present position in the visible columns ( position in oBrw:aCols )
oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nPos ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42483
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Know the Column number clicked on the TXBrowse Header

Post by Antonio Linares »

So using Mr. Rao advise we can simplify the code even more:

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   USE "clients"

   XBROWSER "clients" SETUP oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nCreationOrder ) }

return nil
or

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   USE "clients"

   XBROWSER "clients" SETUP oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nPos ) }

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
INFORMAISVRB
Posts: 51
Joined: Tue Mar 23, 2010 12:53 pm
Contact:

Re: Know the Column number clicked on the TXBrowse Header

Post by INFORMAISVRB »

Thank you all
Solved like this, see the Code

My code

Code: Select all | Expand

oCol := oDBx_Fornecedor:AddCol()
oCol:bStrData  := { || forneced->FANTASIA }
oCol:cHeader   := "Fantasia"
oCol:cFooter   := " "
oCol:nDataStrAlign := AL_LEFT
oCol:nHeadStrAlign := AL_LEFT
oCol:bLClickHeader := {|r,c,f,o| (  oDBx_Fornecedor:cFilterFld :=  'FANTASIA', PROCURA_FORNECED_SQL(cOrder,'FANTASIA',oDBx_Fornecedor:MouseColPos( c ) )    )}
oCol:cSortOrder := 'FANTASIA'
 

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local oBrowser

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol | MsgInfo( oBrowser:MouseColPos( nMCol ) ) } } ) )

return nil
 
Post Reply