FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Sat Apr 22, 2023 09:49 PM
Hola buenas tardes para todos

En este momento requerimos agregar o quitar columnas del xbrowse en tiempo de ejecuci贸n. Ya que estamos intentando generar un reporte din谩mico.

O es necesario volver a crear todo el objeto? si este fuera el caso como se hace? De antemano gracias.


Despu茅s de cambiar la info


El c贸digo que muestra lo que intentamos hacer
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

聽 聽local oWnd, oBar, oBrw, oFont
聽 聽local cNcol, j
聽 聽local atales
聽 聽local aCols1 := {"nombre","apellido","id","dinamica1","dinamica2","dinamica3","dinamica4"}
聽 聽local aColTt := {"El nombre","El apellido","el id","la columna 1","la columna 2","la columna 3","la columna 4"}
聽 聽local aColAn := {100,100,40,80,80,80,80}
聽 聽local cbCambioInfo := <||
聽 聽 聽 聽 aTales := ReadHashArray2() //LLenamos el array con la nueva informaci贸n
聽 聽聽聽 聽 oBrw:aArrayData := aTales聽 聽
聽 聽 聽 聽 oBrw:refresh()
聽 聽>

聽 聽aTales := ReadHashArray() //LLenamos el array con los datos iniciales

聽 聽Define Font oFont Name "Calibri" Size 0,-14 Bold
聽 聽DEFINE WINDOW oWnd TITLE FWVERSION + " : Columnas Dinamicas" 聽
聽 聽oWnd:SetFont( oFont )

聽 聽DEFINE BUTTONBAR oBar OF oWnd SIZE 50,20 2007
聽 聽DEFINE BUTTON OF oBar PROMPT "Cambio" 聽 CENTER ACTION EVAL(cbCambioInfo)

聽 聽SET MESSAGE OF oWnd TO "" 2007
聽 聽
聽 聽 @ oBar:nHeight,0 XBROWSE oBrw ;
聽 聽 SIZE 0 ,0 OF oWnd PIXEL ;
聽 聽 LINES STYLE FLAT NOBORDER ;
聽 聽 DATASOURCE aTales AUTOCOLS 
聽 聽 
聽 聽 ReArrangeCols( oBrw, aCols1 )

聽 聽 WITH OBJECT oBrw
聽 聽 聽 聽 :lRecordSelector 聽 聽聽 聽 := .T.
聽 聽 聽 聽 :lHScroll 聽 聽 聽 聽聽 聽:= .T.
聽 聽 聽 聽 :lVScroll 聽 聽 聽 聽聽 聽:= .T.
聽 聽 聽 聽 :l2007 聽 聽 聽 聽 聽 聽 聽:= .T.
聽 聽 聽 聽 :lFitGridHeight 聽聽 聽聽 聽 := .T.
聽 聽 聽 聽 :nHeaderHeight 聽 聽 聽聽 聽 := 30
聽 聽 聽 聽 :nRowHeight 聽 聽 聽聽 聽:= 21
聽 聽 聽 聽 :nMarqueeStyle 聽 聽 聽聽 聽 := MARQSTYLE_HIGHLROW
聽 聽 聽 聽 :lColDividerComplete 聽 聽:= .t.
聽 聽 聽 聽 :lFullGrid 聽 聽 聽 聽 聽:= .T.
聽 聽 聽 聽 :nStretchCol 聽 聽 聽 聽聽 聽 := STRETCHCOL_LAST
聽 聽 END

聽 聽 WITH OBJECT oBrw

聽 聽 聽 聽 //Colocamos los titulos a las columnas
聽 聽 聽 聽 FOR j:=1 TO len(aCols1)
聽 聽 聽 聽 聽 聽 :aCols[j]:cHeader 聽:= aColTt[j]
聽 聽 聽 聽 聽 聽 :aCols[j]:nWidth = aColAn[j]聽 聽 
聽 聽 聽 聽 NEXT 

聽 聽 END
聽 聽 oBrw:CreateFromCode() 
聽 聽 oWnd:oClient := oBrw

聽 聽ACTIVATE WINDOW oWnd CENTERED

return nil
聽
聽
static function ReadHashArray()

聽 聽local hInfo, aTales := {}

聽 聽hInfo := {=>}
聽 聽hInfo["nombre"] := "LEANDRO"
聽 聽hInfo["apellido"] := "AREVALO"
聽 聽hInfo["id"] := 1
聽 聽hInfo["dinamica1"] := 15000
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica3"] := 35000
聽 聽hInfo["dinamica4"] := 45000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "JUDITH"
聽 聽hInfo["apellido"] := "RIVAS"
聽 聽hInfo["id"] := 2
聽 聽hInfo["dinamica1"] := 15000
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica3"] := 35000
聽 聽hInfo["dinamica4"] := 45000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "ROBERTO"
聽 聽hInfo["apellido"] := "TOTO"
聽 聽hInfo["id"] := 3
聽 聽hInfo["dinamica1"] := 15000
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica3"] := 35000
聽 聽hInfo["dinamica4"] := 45000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "FEDERICO"
聽 聽hInfo["apellido"] := "EXPLICO"
聽 聽hInfo["id"] := 4
聽 聽hInfo["dinamica1"] := 15000
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica3"] := 35000
聽 聽hInfo["dinamica4"] := 45000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "ENTIENDES"
聽 聽hInfo["apellido"] := "MEDEZ"
聽 聽hInfo["id"] := 5
聽 聽hInfo["dinamica1"] := 15000
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica3"] := 35000
聽 聽hInfo["dinamica4"] := 45000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

#ifdef __XHARBOUR__
聽 聽AEval( aTales, { |h| 聽 聽HSetCaseMatch( h, .f. ) } )
#else
聽 聽AEval( aTales, { |h| HB_HSetCaseMatch( h, .f. ) } )
#endif

return aTales

static function ReadHashArray2()

聽 聽local hInfo, aTales := {}

聽 聽hInfo := {=>}
聽 聽hInfo["nombre"] := "LEANDRO"
聽 聽hInfo["apellido"] := "AREVALO"
聽 聽hInfo["id"] := 1
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica5"] := 45000
聽 聽hInfo["dinamica6"] := 55000
聽 聽hInfo["dinamica7"] := 75000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "JUDITH"
聽 聽hInfo["apellido"] := "RIVAS"
聽 聽hInfo["id"] := 2
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica5"] := 45000
聽 聽hInfo["dinamica6"] := 55000
聽 聽hInfo["dinamica7"] := 75000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "ROBERTO"
聽 聽hInfo["apellido"] := "TOTO"
聽 聽hInfo["id"] := 3
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica5"] := 45000
聽 聽hInfo["dinamica6"] := 55000
聽 聽hInfo["dinamica7"] := 75000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "FEDERICO"
聽 聽hInfo["apellido"] := "EXPLICO"
聽 聽hInfo["id"] := 4
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica5"] := 45000
聽 聽hInfo["dinamica6"] := 55000
聽 聽hInfo["dinamica7"] := 75000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

聽 聽hInfo["nombre"] := "ENTIENDES"
聽 聽hInfo["apellido"] := "MEDEZ"
聽 聽hInfo["id"] := 5
聽 聽hInfo["dinamica2"] := 25000
聽 聽hInfo["dinamica5"] := 45000
聽 聽hInfo["dinamica6"] := 55000
聽 聽hInfo["dinamica7"] := 75000
聽 聽AADD(atales,hInfo)
聽 聽hInfo := {=>}

#ifdef __XHARBOUR__
聽 聽AEval( aTales, { |h| 聽 聽HSetCaseMatch( h, .f. ) } )
#else
聽 聽AEval( aTales, { |h| HB_HSetCaseMatch( h, .f. ) } )
#endif

return aTales
聽
聽
function ReArrangeCols( oBrw, aCols )
聽 聽AEval( oBrw:aCols, { |o| o:lHide := .f. } )
聽 聽oBrw:ReArrangeCols( aCols )
聽 聽AEval( oBrw:aCols, { |o| o:lHide := .t. }, Len( aCols ) + 1 )
聽 聽oBrw:Refresh()
return nil
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Sat Apr 22, 2023 10:08 PM

Hola leandro,

has intentado con oBrw:aCols[nNumeroColumna]:Hide()

Quizas te funcione.

"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Sat Apr 22, 2023 11:30 PM

Jose gracias por responder

Pero lo que necesito NO es ocultarlas y mostrarlas (hide/show). El array hash que recibimos, viene con algunas de las columnas diferentes. Son din谩micas.

Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Mon Apr 24, 2023 02:46 AM

Leandro,

En la clase TXBROWSE, existe el METHOD DelCol( nPos )

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Thu Apr 27, 2023 07:50 PM

Amigo gracias por responder...

Si ese m茅todo lo hab铆a encontrado en la clase de xbrowse. El problema que tambien tenemos es como saber si una columna es definida o no en el xbrowse, puede ser por su titulo.

Si tuvieras un ejemplo te lo agradecer铆a.

De antemano gracias

Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Fri Apr 28, 2023 03:34 AM
leandro wrote:Amigo gracias por responder...

Si ese m茅todo lo hab铆a encontrado en la clase de xbrowse. El problema que tambien tenemos es como saber si una columna es definida o no en el xbrowse, puede ser por su titulo.

Si tuvieras un ejemplo te lo agradecer铆a.

De antemano gracias
Code (fw): Select all Collapse
nPos := Ascan( oBrw:aCols, { | o | Lower( o:cHeader ) == Lower( "mi titulo que busco" ) } )
if !Empty( nPos )
聽 聽? "Si existe"
endif
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Fri May 12, 2023 09:57 AM
Excelente Amigo Cris muchas gracias, era lo que hacia falta :D
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Agregar/Quitar columna xbrowse tiempo ejecuci贸n
Posted: Fri May 12, 2023 12:12 PM
If you want to know if a column with a particular header exists in xbrowse
Code (fw): Select all Collapse
oCol := oBrw:oCol( cHeader )
if Empty( oCol )
聽 聽// does not exist
else
聽 // oCol is the column with cHeader
聽 // do whatever you want with oCol
endif
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion