Hola a todos,
Es posible hacer un xBrowse con una array de Hash como elementos ?
Muchas Gracias.
Pere Cordonet
#include "FiveWin.Ch"
#include "xbrowse.ch"
function Main()
local h := {=>}
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
XBROWSER h
return ( 0 )
#include "FiveWin.Ch"
#include "xbrowse.ch"
function Main()
local oDlg, oBrw
local h := {=>}
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
DEFINE DIALOG oDlg
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY h AUTOCOLS HEADERS 'Detail', 'Value' ;
CELL LINES NOBORDER
oBrw:nStretchCol := 1
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
return ( 0 )
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont
local aHash := {}, h
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 30
h:City := 'Boston'
h:JoinDt := {^ 1990/10/02}
h:First := 'Adam'
h:Last := 'Brian'
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 350,200 PIXEL FONT oFont
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY aHash AUTOCOLS ;
CELL LINES NOBORDER
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return ( 0 )
//------------------------------------------------------------------//
pcordonet wrote:Hello nageswaragunupudi
Can you post one sample of array of hashes.
Many, many thanks.
Pere
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 08/26/18, 10:12:23
Error description: Error BASE/1005 No exported variable: AGE
Args:
[ 1] = H {=>}
[ 2] = N 45
Stack Calls
===========
Called from: => _AGE( 0 )
Called from: HASH6.prg => MAIN( 13 )
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont
local aHash := {}, h
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 30
h:City := 'Boston'
h:JoinDt := {^ 1990/10/02}
h:First := 'Adam'
h:Last := 'Brian'
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 350,200 PIXEL FONT oFont
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY aHash AUTOCOLS ;
CELL LINES NOBORDER
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return ( 0 )
//------------------------------------------------------------------//
oBrwItem := TXBrowse():New( oPanelDetL )
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "I.D."
oCol:nWidth := 80
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:cDataType := "N"
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "Descripción del Producto"
oCol:nWidth := 250
oCol:cDataType := "C"
oCol:bStrData := { || oQry:DescripcionProducto } // con un query
*-----------------------------------------------
oBrwItem:SetArray( aHash )
AAdd( aHash, {=>} )
h := ATail( aHash )
h["IdProducto"] := hVarArt["nIdProducto"]
h["NombreProducto"] := hVarArt["cNomPro"]
h["CodigoProducto"] := hVarArt["cCodPro"]
h["Cantidad"] := 1
h["PrecioUnitarioNeto"] := hVarArt["nPreUni"]
h["ImporteNetoItem"] := hVarArt["nPreUni"]
oBrwItem := TXBrowse():New( oPanelDetL )
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "I.D."
oCol:nWidth := 80
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:bStrData := {|| } // con hash?
oCol:cDataType := "N"
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "Descripción del Producto"
oCol:nWidth := 250
oCol:cDataType := "C"
oCol:bStrData := { || oQry:DescripcionProducto } // con un query
oCol:bStrData := {|| } // con hash?
*-----------------------------------------------
oBrwItem:SetArray( aHash )
AAdd( aHash, {=>} )
h := ATail( aHash )
h["IdProducto"] := hVarArt["nIdProducto"]
h["NombreProducto"] := hVarArt["cNomPro"]
h["CodigoProducto"] := hVarArt["cCodPro"]
h["Cantidad"] := 1
h["PrecioUnitarioNeto"] := hVarArt["nPreUni"]
h["ImporteNetoItem"] := hVarArt["nPreUni"]
oCol:bStrData := {|| if(Len( aHash ) > 0 .and. ValType( aHash[ 1 ] ) == 'H', aHash[1]["IdProducto"] ,"" ) }
oCol:bStrData := {|| if(Len( aHash ) > 0 .and. ValType( aHash[ 1 ] ) == 'H', aHash[oBrwItem:nArrayAt]["IdProducto"] ,"" ) }
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 54 guests