AUTOSORT in xBrowse

AUTOSORT in xBrowse

Postby ORibeiro » Thu May 08, 2014 5:19 pm

How do I automatically sort a browse (created with xBrowse) when the user clicks on a column?
 
I am creating this:

Code: Select all  Expand view

********************************************************************************************
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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: AUTOSORT in xBrowse

Postby ORibeiro » 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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: AUTOSORT in xBrowse

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: AUTOSORT in xBrowse

Postby ORibeiro » Fri May 09, 2014 1: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
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: AUTOSORT in xBrowse

Postby nageswaragunupudi » Fri May 09, 2014 4:50 pm

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

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 8 guests