FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour AUTOSORT in xBrowse
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
AUTOSORT in xBrowse
Posted: Thu May 08, 2014 05:19 PM
How do I automatically sort a browse (created with xBrowse) when the user clicks on a column?
 
I am creating this:

Code (fw): Select all Collapse
********************************************************************************************
Static function detal_Res(cDbf_p,cPro,wTit)
********************************************************************************************
   Select(cDbf_p)
   DbGoTop()
   If wTit = "PD"
      cTit := "RESUMO DOS PEDIDOS PENDENTES DO PRODUTO: "+Alltrim(cPro)
   Elseif wTit = "CP"
      cTit := "RESUMO DOS PEDIDOS DE COMPRA PENDENTES DO PRODUTO: "+Alltrim(cPro)
   Else
      cTit := "RESUMO DAS ORDENS DE MANUFATURA PENDENTES DO PRODUTO: "+Alltrim(cPro)
   Endif
   DEFINE DIALOG oDlg SIZE 800,420 FONT WndMain():oFont TITLE cTit TRANSPARENT
      @ 10,10 XBROWSE oBrw OF oDlg SIZE 380,180 PIXEL;
              ALIAS (cDbf_p);
              AUTOSORT AUTOCOLS FOOTERS LINES CELL
      oBrw:DT_EMISS:cEditPicture := 'dd/mm/yyyy'
      oBrw:DT_PREV:cEditPicture  := 'dd/mm/yyyy'
      oBrw:DelCol( 1 ) // Deleta Coluna
      AEval( oBrw:aCols, { |o| o:cToolTip := { 'Column :' + CRLF + o:cHeader, 'ToolTip' } } )     // ToolTip nas colunas
      oBrw:bClrStd := {|| {CLR_BLACK, iif(oBrw:Keyno()%2=0, CLR_WHITE, CLR_HGRAY) } }             // Cores nas linhas (Par/Impar) ou (oBrw:cAlias)->(RecN())%2=0
      oBrw:CreateFromCode()
      @ 195, 010 BUTTON "&Imprimir" SIZE 50,10 FONT oFontGet PIXEL ACTION IIF( MsgYesNo("Deseja imprimir essa planilha?","Confirme"), Listar(cTit,,,,,,,,,,,,,.F.), )
      @ 195, 070 BUTTON "&Excel"    SIZE 50,10 FONT oFontGet PIXEL ACTION oBrw:ToExcel()
      @ 195, 130 BUTTON "&Fechar"   SIZE 50,10 FONT oFontGet PIXEL ACTION oDlg:End()
   ACTIVATE DIALOG oDlg CENTERED;
      ON INIT oBrw:SetFocus()
Return(.T.)
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: AUTOSORT in xBrowse
Posted: Fri May 09, 2014 10:17 AM

I found the problem:

When I change the column headings in a way that they differ from the names of the fields does not xBrowse makes AutoSort.

Is there any way to fix this?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: AUTOSORT in xBrowse
Posted: Fri May 09, 2014 10:30 AM

Autosort should work even if column header names are changed and are different.

Autosort works if the fields are indexed and the index is open.
If index is open, XBrowse searches all open index tags to find index tag orders corresponding to each column based on the column name specified. In case of autocols, based on field names.

Please make sure the fields are indexed and index(es) are open.

However, if the index expressions are too complex xbrowse may not be able to find the correct index tag to use. This is very rare. In such cases you may use clause
SORT "TAG1", "TAG2", .... etc
to tell xbrowse explicitly to use particular tags corresponding to each column.

Regards



G. N. Rao.

Hyderabad, India
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: AUTOSORT in xBrowse
Posted: Fri May 09, 2014 01:47 PM

Thanks Ral,

In this case there is no way to change the description of the column headings, but the xBrowse not find the tag, right?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: AUTOSORT in xBrowse
Posted: Fri May 09, 2014 04:50 PM

You can change the column headings as you like.
That does not affect the autosort behavior.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion