XBROWSE AUTOSORT dont work

XBROWSE AUTOSORT dont work

Postby avista » Thu Mar 01, 2012 1:42 pm

Hi all
Please help or some sugestions.
In this sample AUTOSORT dont work
Code: Select all  Expand view
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function MyBrowse()

   local oDlg, oBrw, cAlias

   RddSetDefault("DBFCDX")

   USE TESTDBF  NEW SHARED

   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 900,500

   cAlias := Alias()

   @ 32.5, 0 XBROWSE oBrw ;
            OF oDlg SIZE 400,200 PIXEL ;
            ALIAS cAlias ;
            AUTOCOLS AUTOSORT FOOTERS LINES CELL ;
            BACKGROUND 'STONE'

   oBrw:CreateFromCode()


   ACTIVATE DIALOG oDlg CENTERED

   (cAlias)->( dbCloseArea() )

return nil


If i use dbf file CUSTOMER in \fwh\samples folder going good
What that mean ?

Need i to create index file before defining XBROWSE ? And if yes how to create index file ?
BTW i really dont know the dbf file name becouse it is created from SQL select using TODBC and TDBODBCD classes
and i dont know the fieldnames.

Best Regards and again i please for fast sugestion.
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE AUTOSORT dont work

Postby avista » Fri Mar 02, 2012 2:47 pm

?
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE AUTOSORT dont work

Postby nageswaragunupudi » Fri Mar 02, 2012 10:10 pm

AUTOSORT while browsing DBF files works only for columns where index exists in the corresponding index file opened in the workarea.
Regards

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

Re: XBROWSE AUTOSORT dont work

Postby nageswaragunupudi » Fri Mar 02, 2012 10:18 pm

In your case, the Alias() is known but you say you do not know the filename or field names. You can still use this function to create temporary index on all the fields. Add these functions to your code and call ( Alias() )->( CreateTempCdx() ) before creating xbrowse.

Code: Select all  Expand view
//----------------------------------------------------------------------------//

function CreateTempCdx()

   local n

   for n := 1 to FCount()
      CreateTempTag( FieldName( n ), FieldType( n ) )
   next

return nil

//----------------------------------------------------------------------------//

static function CreateTag( ctag, cType )

   PRIVATE cExpr

   if cType == 'C'
      cExpr    := "UPPER(" + Trim( cTag ) + ")"
      INDEX ON &cExpr TAG &cTag TO TEMP TEMPORARY
   else
      INDEX ON &ctag TAG &ctag TO TEMP TEMPORARY
   endif

return nil

//----------------------------------------------------------------------------//
 
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests