Sorting xBrowse by clicking on header

Sorting xBrowse by clicking on header

Postby PeterHarmes » Fri Jan 20, 2012 4:29 pm

Hi,

I have an address book browse (on a dbf &/or a SQL table using SQLRDD) and when I click on the header, the browse changes order.

The way I currently do this is:

Code: Select all  Expand view

oCol:blClickHeader := {|| ( CUSTSITE->(DBSETORDER("CUSTSITE")), CUSTSITE->(cmxsetscope(0,{|| STR(SITE_DET->SITE_ID,2,0)})), CUSTSITE->(cmxsetscope(1,{|| STR(SITE_DET->SITE_ID,2,0)})),oBrw:refresh())}

or

oCol:blClickHeader := {|| (CUSTOMER->(DBSETORDER("CUSTOMER")), oBrw:Refresh())}
 


Two questions:

1. Is this the correct way to do this or is there an easier way to do this?

2. How do I update the header with a symbol to say which column is sorted (must clear previous symbol of previous sorted column)

Thanks in advance

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Sorting xBrowse by clicking on header

Postby frose » Sat Jan 21, 2012 9:54 am

Peter,

here is the frame code, how I sets my favorite sorting bitmaps:
Code: Select all  Expand view

// in Browse definitions
   oCol := oBrw:AddCol()
         //
         // Resourcen
         //
         //oCol:AddResource( "SORT_ASCEND_ACTIV" )
         //oCol:AddResource( "SORT_ASCEND_INACTIV" )
         //oCol:AddResource( "SORT_DESCEND_ACTIV" )
         //oCol:AddResource( "SORT_DESCEND_INACTIV" )
         //
         // or file system
         //
         oCol:AddBmpFile( cPicturePath + "sort_ascend_activ.bmp" )
         oCol:AddBmpFile( cPicturePath + "sort_ascend_inactiv.bmp" )
         oCol:AddBmpFile( cPicturePath + "sort_descend_activ.bmp" )
         oCol:AddBmpFile( cPicturePath + "sort_descend_inactiv.bmp" )

...
         oCol:bLClickHeader := &( "{ | nMRow, nMCol, nFlags, oCol | Set_Sorting( nMRow, nMCol, nFlags, oCol ) }" )
...
FUNCTION Set_Sorting( nMRow, nMCol, nFlags, oCol )
// logic to set the appropiate bitmap and the color of the sorted column
...
      oCol:nHeadBmpNo := 0 ... 4
      // sorted color
      oCol:bClrStd := { || { CLR_BLACK, RGB( 231, 242, 255 ) } }
      // or, if not sorted
      oCol:bClrStd := { || { CLR_BLACK, CLR_WHITE } }
...
RETURN NIL
 


Here are the bitmaps:
http://www.filesonic.com/file/tbmXrfV

and a screen shot:
Image


HTH
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests