FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Consulta xBrowse
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Consulta xBrowse
Posted: Fri Feb 18, 2011 01:57 PM
Gente:
Estoy comenzando con el uso de xBrowse (disculpas amigo Checcarrelli, pero el amor no es eterno :-) ).
Estoy listando una tabla mySQL. La consulta es: como indicar que ordene por la columna x al hacer clic sobre la misma
Uso Ealge6, que para ordenar por una columna dispongo del metodo :SetOrderBy( nCol,, TRUE ). Debo usarlo? o xbrowse prescinde de el?
Pretendo que quede as铆:


y Tambi茅n (por el mismo precio :-) ), quisiera agregar color. Es decir que la columna que indica el orden ademas del icono tenga el color que le indico

muchas gracias
Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Consulta xBrowse
Posted: Fri Feb 18, 2011 03:46 PM
Gente;
por ahora lo solucion茅 as铆
Code (fw): Select all Collapse
聽 聽::aoTB[SFO_OBRAS]:SetOrderBy( nCol,, TRUE )
聽 聽::oBrw:aCols[nCol]:oHeaderFont:= ::hFont["SysFontB"]
聽 聽::oBrw:aCols[nCol]:bClrHeader:= {|| { CLR_HBLUE, if( ::oBrw:l2007, nRGB( 231, 242, 255 ), GetSysColor( COLOR_BTNFACE ) ) } }
聽 聽aEval( ::oBrw:aCols, {|o,n| nColAct:= n, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽if( !nColAct == nCol, o:bClrHeader:= {|| { CLR_BLACK, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if( ::oBrw:l2007, nRGB( 231, 242, 255 ), GetSysColor( COLOR_BTNFACE ) ) } }, ) ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽})
聽 聽::oBrw:GoTop()
聽 聽::oBrw:Refresh()


y se v茅 as铆:


Solo por curiosidad. Se puede hacer que muestre el icono de la columna que tiene el orden activo?, como?

muchas gracias
Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Consulta xBrowse
Posted: Sat Feb 19, 2011 06:10 AM
If understand you correctly,
When the user clicks on header of column, (a) that column must be sorted using your sort function, (b) the column header should be shown in different color and (c) arrow bitmap should be shown in the header of the column.

This is the shortest code to achieve this: You need to set these codeblocks for each column you want to be sorted
Code (fw): Select all Collapse
oCol:cSortOrder := { |o| <YourSortFuntion>(<your params>), 聽'A' } // Return 'A' if sorted ascending and return 'D' if sorted discending

oCol:bClrHeader := { || If( Empty( oCol:cOrder ), { normal color pair }, { sorted color pair } ) }


How it works?:

Each column of XBrowse has a DATA cOrder. For sorted column, it is 'A' or 'D' and for all other columns it is Empty. XBrowse internally assigns these values. XBrowse shows UpArrow bitmap for the column where cOrder is 'A' or downarrow bitmap if cOrder is 'D' and no sort bitmaps for all other columns.

When use clicks on Header of a Column, XBrowse checks for the value in the column's DATA cSortOrder. If the value is codeblock, it executes the codeblock and assigns the return value to cOrder and redraws the headers.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Consulta xBrowse
Posted: Sat Feb 19, 2011 02:02 PM

G.N.Rao
many thanks; that is what needed

regards

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Consulta xBrowse - TEMA CERRADO
Posted: Mon Feb 21, 2011 02:10 PM

muchas gracias

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Consulta xBrowse
Posted: Mon Feb 21, 2011 03:43 PM
Disculpas, por haber escrito TEMA CERRADO
Algo debo estar haciendo mal. He cambiado el c贸digo de acuerdo a lo indicado por Rao, pero el efecto no es el esperado
(Rao, something is wrong in my code)

Code (fw): Select all Collapse
...
聽 聽// Browse
聽 聽WITH OBJECT ::oBrw:= ::SetdefaultBrws( h1:oWTab )
聽 聽 聽 :nFreeze:= 2
聽 聽END
聽 聽// IDObra
聽 聽WITH Object oCol:= ::oBrw:AddCol()
聽 聽 聽 ::SetDefaultCol( oCol, _CodObra )

聽 聽 聽 :bStrData 聽 聽 := {|| hb_ValToStr( ::aoTB[SFO_OBRAS]:FieldGet( Tb_CodObra ) ) }
聽 聽 聽 :bLClickHeader:= {|| ::Ordenar( _CodObra ) }
聽 聽END
聽 聽// Descripcion
聽 聽WITH Object oCol:= ::oBrw:AddCol()
聽 聽 聽 ::SetDefaultCol( oCol, _Desc_Obra )

聽 聽 聽 :bStrData 聽 聽 := {|| hb_ValToStr( ::aoTB[SFO_OBRAS]:FieldGet( Tb_Desc_Obra ) ) }
聽 聽 聽 :bLClickHeader:= {|| ::Ordenar( _Desc_Obra ) }
聽 聽END
聽 聽// Precio
聽 聽WITH Object oCol:= ::oBrw:AddCol()
聽 聽 聽 ::SetDefaultCol( oCol, _Precio_Ofic 聽)

聽 聽 聽 :bStrData 聽 聽 := {|| Trans( ::aoTB[SFO_OBRAS]:FieldGet( Tb_Prec_Ofic ), PIC_ONCE ) }
聽 聽 聽 :bLClickHeader:= {|| ::Ordenar( _Precio_Ofic 聽) }
聽 聽END

聽 聽WITH OBJECT ::oBrw
聽 聽 聽 :SetMySql( ::aoTB[SFO_OBRAS], .f. )
聽 聽 聽 :bSkip := { | n | ::oBrw:oMysql:Skipper( n ) }

聽 聽 聽 :CreateFromCode()
聽 聽END

聽 聽h1:oWTab:oClient:= ::oBrw
聽 聽::oBrw:SetFocus()

聽 聽return( nil )

// ------------------------
METHOD Ordenar( nCol ) 聽 CLASS TSFOTablas
聽 聽WITH OBJECT oCol:= ::oBrw:aCols[nCol]
聽 聽 聽 :cSortOrder := {|o| ::aoTB[SFO_OBRAS]:SetOrderBy( nCol,, TRUE ), "A" }
聽 聽 聽 :bClrHeader := {|o| If( Empty( oCol:cOrder ), { CLR_BLACK, GetSysColor( COLOR_BTNFACE ) }, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 { CLR_HBLUE, GetSysColor( COLOR_BTNFACE ) } ) }
聽 聽END
聽 聽::oBrw:GoTop()
聽 聽::oBrw:Refresh()

聽 聽return( nil )


Al ejecutar la aplicaci贸n y hacer clic en cada columna, la primera vez, no ocurre nada; la segunda vez ordena como se espera.
Ahora bien, en acciones siguientes, al hacer solo un clic, ya se produce el efecto.
Que falta?

Rao, sorry for my english
When run my app and click in each column, the first time, nothing do. If I click again, in any column, the sort it happens.
what is lacking?

regards
Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM
Re: Consulta xBrowse
Posted: Thu Feb 24, 2011 02:14 PM
Gente:
Esta soluci贸n no funciona:
Code (fw): Select all Collapse
// ------------------------
METHOD Ordenar( nCol ) 聽 CLASS TSFOTablas
聽 聽WITH OBJECT oCol:= ::oBrw:aCols[nCol]
聽 聽 聽 :cSortOrder := {|o| ::aoTB[SFO_OBRAS]:SetOrderBy( nCol,, TRUE ), "A" }
聽 聽 聽 :bClrHeader := {|o| If( Empty( oCol:cOrder ), { CLR_BLACK, GetSysColor( COLOR_BTNFACE ) }, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 { CLR_HBLUE, GetSysColor( COLOR_BTNFACE ) } ) }
聽 聽END
...

Por alguna raz贸n que no entiendo, para que funcione, debo hacer un primer clic sobre una columna y, a partir de los clic siguientes el efecto si funciona de acuerdo a lo esperado.

Por ahora lo soluciono as铆:
Code (fw): Select all Collapse
聽 聽::aoTB[SFO_OBRAS]:SetOrderBy( nCol,, TRUE )
聽 聽aEval( ::oBrw:aCols, {|o| o:cOrder:= "", ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽o:oHeaderFont:= ::oBrw:oFont } )
聽 聽WITH OBJECT oCol:= ::oBrw:aCols[nCol]
聽 聽 聽 :cOrder 聽 聽 := "A"
聽 聽 聽 :oHeaderFont:= ::hFont["SysFontB"]
聽 聽 聽 :bClrHeader := {|o| if( Empty( oCol:cOrder ), { CLR_BLACK, GetSysColor( COLOR_BTNFACE ) }, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 { CLR_HBLUE, GetSysColor( COLOR_BTNFACE ) } ) }
聽 聽END
Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina

Continue the discussion