Cambiar Tree Completo Sobre xBrowse (solucionado)

Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby leandro » Fri Mar 04, 2022 11:12 pm

Hola buenas tardes para todos

Estoy intentando cambiar por completo el oTree que tengo montado sobre el xbrowse, intento usar la función oBrw:settree() pero lo que hace es sobre poner las columnas que se están mostrando.

Si se hace varias veces clic sobre el botón de cambio, se aumentan mas y mas columnas.

Image

Code: Select all  Expand view

#include "fivewin.ch"

function Main()

local oTree, oFont2, oBtCmb
local oDlg, oFont, oBrw

Local cbCambioEstado := <|x|
    oBrw:oTreeItem:Cargo[2] := x
    oBrw:refresh()
>

Local cbCambioTree := <||
    oTree := buildtree2()
    oBrw:SetTree(oTree)
    oBrw:refresh() 
    oTree:OpenAll() 
>

oTree := buildtree1()

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE FONT oFont2 NAME "TAHOMA" SIZE 0,-9

DEFINE DIALOG oDlg SIZE 700,500 PIXEL TRUEPIXEL FONT oFont

    @ 0, 20 BUTTONBMP oBtCmb OF oDlg PIXEL size 80, 21 PROMPT "Cambiar oTree" FONT oFont2 ACTION EVAL(cbCambioTree) 

    @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
    DATASOURCE oTree ;
    COLUMNS 2 ;
    HEADERS "ITEM", "AUTO";
    CELL LINES NOBORDER

    WITH OBJECT oBrw
    :lDisplayZeros := .f.
    :aCols[ 1 ]:AddBitmap( { FWDArrow(), FWRArrow(), GetTreeBmps()[ 2 ] } )

    :aCols[2]:bEditValue := {|| oBrw:oTreeItem:Cargo[2] }
    :aCols[2]:cDataType  := "L"
    :aCols[2]:nEditType := EDIT_GET
    :aCols[2]:SetCheck()
    :aCols[2]:bOnPostEdit    := { | o, x, n | EVAL(cbCambioEstado,x) }     

    :bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:nLevel == 1, CLR_YELLOW, CLR_WHITE ) } }

    :CreateFromCode()
    END
    oTree:OpenAll()

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont

return nil

//CONSTRUIMOS EL PRIMER TREE
function buildtree1()
Local oTree
Local aData := {}
Local aData2 := {}
Local t,r

aData    := ;
{  { "Facturas", 00,.T.  } ;
,  { "Pedidos", 00,.F. } ;
,  { "Remsiones", 00,.F. } ;
,  { "Notas", 00,.F. } ;
}

aData2    := ;
{  { "Agregar ", 01,.T. } ;
,  { "Modificar ", 02,.T. } ;
}

TREE oTree
FOR r:=1 TO len(aData)
    TREEITEM aData[r][1] CARGO {  aData[r][2] , aData[r][3]  }     
    TREE
    FOR t:=1 TO len(aData2)
        TREEITEM aData2[t][1] CARGO { aData2[t][2] , aData2[t][3]  }
    NEXT  
    ENDTREE
NEXT   
ENDTREE

Return oTree

//CONSTRUIMOS EL SEGUNDO TREE
function buildtree2()
Local oTree
Local aData := {}
Local aData2 := {}
Local t,r

aData    := ;
{  { "Cuentas", 00,.T.  } ;
,  { "Comprobantes", 00,.F. } ;
,  { "Centros", 00,.F. } ;
,  { "Conceptos", 00,.F. } ;
,  { "Consultas", 00,.F. } ;
}

aData2    := ;
{  { "Eliminar", 00,.T. } ;
,  { "Enviar ", 00,.T. } ;
,  { "Procesar ", 00,.T. } ;
,  { "Anular ", 00,.T. } ;
}

TREE oTree
FOR r:=1 TO len(aData)
    TREEITEM aData[r][1] CARGO {  aData[r][2] , aData[r][3]  }     
    TREE
    FOR t:=1 TO len(aData2)
        TREEITEM aData2[t][1] CARGO { aData2[t][2] , aData2[t][3]  }
    NEXT  
    ENDTREE
NEXT   
ENDTREE

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

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1481
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Cambiar Tree Completo Sobre xBrowse

Postby Antonio Linares » Sat Mar 05, 2022 8:33 am

Estimado Leandro,

Esto tiene que revisarlo Rao. Se lo comento, gracias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cambiar Tree Completo Sobre xBrowse

Postby nageswaragunupudi » Sat Mar 05, 2022 12:30 pm

Use this code
Code: Select all  Expand view
Local cbCambioTree := <||
    oTree := buildtree2()
    oBrw:oTree := oTree
    oBrw:GoTop()
    oBrw:refresh()
    oTree:OpenAll()
    oBrw:SetFocus()
    return nil
>
 
Regards

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

Re: Cambiar Tree Completo Sobre xBrowse

Postby nageswaragunupudi » Sat Mar 05, 2022 1:06 pm

Remove this code:
Code: Select all  Expand view

    :aCols[2]:bEditValue := {|| oBrw:oTreeItem:Cargo[2] }
    :aCols[2]:cDataType  := "L"
    :aCols[2]:nEditType := EDIT_GET
    :aCols[2]:SetCheck()
    :aCols[2]:bOnPostEdit    := { | o, x, n | EVAL(cbCambioEstado,x) }
 

This one line of code is recommended.
Code: Select all  Expand view

    :aCols[ 2 ]:SetCheck( nil, .t. )
 


XBrowse automatically creates codeblocks bEditValue and bOnPostEdit. Better not to override them.
Regards

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

Re: Cambiar Tree Completo Sobre xBrowse

Postby leandro » Sat Mar 05, 2022 2:33 pm

Excelente Mr Rao, muchas gracias. :D :D :D

Lo único es que deje bOnPostEdit, por que necesito ejecutar una acción sobre la base de datos, diferente a cambiar el setcheck.

El código quedo de la siguiente manera:

Code: Select all  Expand view

#include "fivewin.ch"

function Main()

local oTree, oFont2, oBtCmb
local oDlg, oFont, oBrw

Local cbCambioEstado := <|x|
    //Aqui ejecuto mi acción personalizada, sobre la base de datos
    oBrw:oTreeItem:Cargo[2] := x
    oBrw:refresh()
>

Local cbCambioTree := <||
    oTree := buildtree2()
    oBrw:oTree := oTree
    oBrw:GoTop()
    oBrw:refresh()
    oTree:OpenAll()
    oBrw:SetFocus()
    return nil 
>

oTree := buildtree1()

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
DEFINE FONT oFont2 NAME "TAHOMA" SIZE 0,-9

DEFINE DIALOG oDlg SIZE 700,500 PIXEL TRUEPIXEL FONT oFont

    @ 0, 20 BUTTONBMP oBtCmb OF oDlg PIXEL size 80, 21 PROMPT "Cambiar oTree" FONT oFont2 ACTION EVAL(cbCambioTree) 

    @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
    DATASOURCE oTree ;
    COLUMNS 2 ;
    HEADERS "ITEM", "AUTO";
    CELL LINES NOBORDER

    WITH OBJECT oBrw
    :lDisplayZeros := .f.
    :aCols[ 1 ]:AddBitmap( { FWDArrow(), FWRArrow(), GetTreeBmps()[ 2 ] } )

    :aCols[ 2 ]:SetCheck( nil, .t. )
    :aCols[ 2 ]:bOnPostEdit    := { | o, x, n | EVAL(cbCambioEstado,x) }

    :bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:nLevel == 1, CLR_YELLOW, CLR_WHITE ) } }

    :CreateFromCode()
    END
    oTree:OpenAll()

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont

return nil

//CONSTRUIMOS EL PRIMER TREE
function buildtree1()
Local oTree
Local aData := {}
Local aData2 := {}
Local t,r

aData    := ;
{  { "Facturas", 00,.T.  } ;
,  { "Pedidos", 00,.F. } ;
,  { "Remsiones", 00,.F. } ;
,  { "Notas", 00,.F. } ;
}

aData2    := ;
{  { "Agregar ", 01,.T. } ;
,  { "Modificar ", 02,.T. } ;
}

TREE oTree
FOR r:=1 TO len(aData)
    TREEITEM aData[r][1] CARGO {  aData[r][2] , aData[r][3]  }     
    TREE
    FOR t:=1 TO len(aData2)
        TREEITEM aData2[t][1] CARGO { aData2[t][2] , aData2[t][3]  }
    NEXT  
    ENDTREE
NEXT   
ENDTREE

Return oTree

//CONSTRUIMOS EL SEGUNDO TREE
function buildtree2()
Local oTree
Local aData := {}
Local aData2 := {}
Local t,r

aData    := ;
{  { "Cuentas", 00,.T.  } ;
,  { "Comprobantes", 00,.F. } ;
,  { "Centros", 00,.F. } ;
,  { "Conceptos", 00,.F. } ;
,  { "Consultas", 00,.F. } ;
}

aData2    := ;
{  { "Eliminar", 00,.T. } ;
,  { "Enviar ", 00,.T. } ;
,  { "Procesar ", 00,.T. } ;
,  { "Anular ", 00,.T. } ;
}

TREE oTree
FOR r:=1 TO len(aData)
    TREEITEM aData[r][1] CARGO {  aData[r][2] , aData[r][3]  }     
    TREE
    FOR t:=1 TO len(aData2)
        TREEITEM aData2[t][1] CARGO { aData2[t][2] , aData2[t][3]  }
    NEXT  
    ENDTREE
NEXT   
ENDTREE

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

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1481
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby nageswaragunupudi » Thu Mar 10, 2022 9:25 am

Lo único es que deje bOnPostEdit, por que necesito ejecutar una acción sobre la base de datos, diferente a cambiar el setcheck.

Instead we recommend using
Code: Select all  Expand view

oCol:bOnChange := { |oCol,uOldVal| <OtherChanges>( oCol,uOldVal ) }
 

To the extent possible, please avoid coding bOnPostEdit. It is deprecated.
Regards

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

Re: Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby goosfancito » Sat Jan 20, 2024 2:59 pm

Estimado,
El campo que tengo en mysql es del tipo
"N" de 1.

este campo lo quiero mostrar en el browser con la capacidad del checkbox, pero al momento no logro hacerlo.
la unica forma que, al menos me mostró la tilde, fue esta:

Code: Select all  Expand view
 WITH OBJECT :acols[ 7 ]
         :bEditValue    := { | x | IIf( ::oQry:FieldGet( "c13" ) > 0, .T., .F. ) }
         :SetCheck(, .T. )
      ENDWITH


pero sola me la muestra con o sin tilde, lo. que necesito es que cambie el estado de la tilde, por lo que necesito ir y actualizar la tabla, pero cuando quiero usar la tabla pero no se con que metodo. podes ayudarme?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby nageswaragunupudi » Sat Jan 20, 2024 6:05 pm

Code: Select all  Expand view

WITH OBJECT :acols[ 7 ]
   :bEditValue := { | x | If( x == nil, ::oQry:FieldGet( "c13" ) > 0, ::oQry:FieldPut( "c13", If( x, 1, 0 ) ) }
   :SetCheck(, .T. )
ENDWITH
 


OR
Code: Select all  Expand view

WITH OBJECT :acols[ 7 ]
   :bEditValue := { | x | If( x == nil, ::oQry:c13 != 0, ::oQry:c13 := If( x, 1, 0 ) ) }
   :SetCheck(, .T. )
ENDWITH
 



If field "c13" type is TinyInt,
Set
Code: Select all  Expand view

MYSQL_TINYINTASLOGICAL( .T. )
 


and then
Code: Select all  Expand view

WITH OBJECT :acols[ 7 ]
   :bEditValue := { | x | If( x == nil, ::oQry:c13, ::oQry:c13 := x ) }
   :SetCheck(, .T. )
ENDWITH
 
Regards

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

Re: Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby goosfancito » Sun Jan 21, 2024 6:27 am

Rao,
Buen dia, la unica manera de que funcione en mi caso es hacerlo asi

Code: Select all  Expand view
     WITH OBJECT :c13
         :setcheck(, .T. )
         :bLDClickData := { || ::actualizarTag()  }
      ENDWITH


PERO ni este ni ningun browser. me esta actualizando los datos, tengo que salir del dialogo y volver a entrar. y ya probe con :oqry:requery
las consultas las hago por procedimientos almacenados


Code: Select all  Expand view
METHOD actualizarTag( x )  CLASS TCliente

   DO CASE
   CASE  ::oBrw:nColSel = 7

      ::oCnx:update( "tbinfissi", ;
                     { ;
                       { "inf_p", !::oQry:FieldGet( "c13" ) } ;
                     }, NIL, ;
                     { { "id", ::oQry:FieldGet( "id" ) } } ;
                   )


   END CASE
   ::oqry:refresh()       <-------------- no funciona
   ::obrw:refresh()
   RETURN ( NIL )
 
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Cambiar Tree Completo Sobre xBrowse (solucionado)

Postby Silvio.Falconi » Mon Jan 22, 2024 9:08 am

Dear Rao,
a question
if I have an xbrowse with customer.dbf (with a combobox to select the indexes and a get to search for customers - see the example diagram below)

Code: Select all  Expand view
USE CUSTOMER....

 DEFINE DIALOG oDlg


@ 10, 165 GET oGet VAR cSeek SIZE 200,19 PIXEL OF oDlg PICTURE "@!"


   @ 103,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg

 WITH OBJECT oBrw
          :oSeek := oGet
            :CreateFromCode()
         END

  @ 10, 550 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder



How can I switch to a tree view in the same xbrowse and viceversa?

And when I'm in the tree view how can I use a combobox to select the tree indexes and use the customer search get?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests