Gente;
alguien que me pueda brindar un ejemplo sencillo.
gracias
Resistencia - "Ciudad de las Esculturas"
Chaco - Argentina
Chaco - Argentina
Gente;
alguien que me pueda brindar un ejemplo sencillo.
gracias
// Browse Obras
oQryOb:= oConx:SelectObras()
oTree := ::MakeTree( oQryOb )
@ 0, 0 XBROWSE oBrwOb COLUMNS "desc_tipo","desc_obra" OBJECT oQryOb OF ::aoMn[_OL2003]:aDialogs[1] SIZE ::aoMn[_OL2003]:aDialogs[ 1 ]:nWidth-2, 250 PIXEL
oBrwOb:SetTree( oTree, ; // Tree object
{ "OPEN","CLOSE","GREEN" } ) // [Optional] Bitmap Resources Open, Close and NoChildren
ADD TO oBrwOb DATA oBrwOb:oTreeItem:Cargo[ 1 ]
ADD TO oBrwOb DATA oBrwOb:oTreeItem:Cargo[ 2 ]
WITH OBJECT oBrwOb
:lHScroll:= FALSE
:CreateFromCode()
END
...
//
METHOD MakeTree( oQryOb ) CLASS Menues
local oTree
local cState
oQryOb:GoTop()
TREE oTree
while !oQryOb:Eof()
if oQryOb:desc_tipo == cState
_TreeItem( oQryOb:desc_tipo ):Cargo := { oQryOb:desc_obra }
else
if cState != nil
ENDTREE
endif
_TreeItem( oQryOb:desc_tipo ):Cargo := { oQryOb:desc_obra }
cState := oQryOb:desc_tipo
TREE
endif
oQryOb:Skip( 1 )
enddo
ENDTREE
ENDTREE
oQryOb:GoTop()
return( oTree )
// FinHola Mario
podrias colocarnos un ejemplo autocontenido que podamos construir para probar lo que estas haciendo...
gracias
#INCLUDE "fivewin.ch"
FUNCTION Main()
LOCAL oTest := TestTree():New()
oTest:Run()
RETURN NIL
CLASS TestTree
DATA oWnd
DATA oCon
DATA oRs
METHOD New()
METHOD MainMenu()
METHOD Run()
METHOD TreeBrowse(n)
METHOD MakeTree(n)
METHOD TDolphinGetTotals()
METHOD TDolphinGetsummary()
METHOD ConnectToDolphin()
ENDCLASS
METHOD TestTree:New()
DEFINE WINDOW ::oWnd MDI ;
TITLE "Test Xbrowse" ;
MENU ::MainMenu()
SET MESSAGE OF ::oWnd TO "Testing XBrowse" 2010
RETURN Self
METHOD TestTree:Run()
ACTIVATE WINDOW ::oWnd
RETURN NIL
METHOD TestTree:MainMenu()
LOCAL oMenu, oSelf := Self
MENU oMenu 2010
MENUITEM "Tree Browse"
MENU
MENUITEM "Method,1" ACTION oSelf:TreeBrowse( 1 )
MENUITEM "Method.2" ACTION oSelf:TreeBrowse( 2 )
ENDMENU
oMenu:AddMdi()
ENDMENU
RETURN oMenu
METHOD TestTree:TreeBrowse( nMethod )
LOCAL oTree, oItem, oBold, oBrw, oRs, oRsTot, oWnd
oRs = ::TDolphinGetsummary()
oTree = ::MakeTree( oRs, nMethod )
oItem = oTree:oFirst
// Setup Browse
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE WINDOW oWnd MDICHILD OF ::oWnd() ;
TITLE If( nMethod == 1, ;
"Tree Browse with data", ;
"Tree Browse with data from Linked Recordset" )
@ 0,0 XBROWSE oBrw OF oWnd LINES CELL
if nMethod == 1
oBrw:SetTree( oTree, ; // Tree object
{ "OPEN","CLOSE","GREEN" } ) // [Optional] Bitmap Resources Open, Close and NoChildren
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] PICTURE "9999" HEADER "Employees"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] PICTURE "999,999,999.99" HEADER "TotSalary"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] / oBrw:oTreeItem:Cargo[ 1 ] ;
PICTURE "999,999,999.99" HEADER "AvgSalary"
else
oBrw:SetTree( oTree, ; // Tree object
{ "OPEN","CLOSE","GREEN" }, ; // [Optional] Bitmap Resources Open, Close and NoChildren
{ | OItem | oRs:nRecNo := oItem:Cargo } ) // To Sync DataSource with oItem
ADD TO oBrw DATA oRs:employees PICTURE "9999" HEADER "Employees"
ADD TO oBrw DATA oRs:totSalary PICTURE "999,999,999.99" HEADER "TotSalary"
ADD TO oBrw DATA oRs:totSalary / oRs:employees ;
PICTURE "999,999,999.99" HEADER "AvgSalary"
endif
oBrw:aCols[ 1 ]:cHeader := "State / City"
// If different fonts are required on the basis of oItem:nLevel
AEval( oBrw:aCols, { |oCol| oCol:oDataFont := { || If( oBrw:oTreeItem:nLevel == 1, oBold, oBrw:oFont ) } } )
// Get Totals for footers
oRsTot := ::TDolphinGetTotals()
// Set Totals in Footers
oBrw:lFooter := .t.
oBrw:aCols[ 1 ]:cFooter := "Total"
oBrw:aCols[ 2 ]:cFooter := oRsTot:FieldGet( 1 )
oBrw:aCols[ 3 ]:cFooter := oRsTot:FieldGet( 2 )
oBrw:aCols[ 4 ]:cFooter := oRsTot:FieldGet( 2 ) / oRsTot:FieldGet( 1 )
oRsTot:End()
// note: cFooter can be of any data type. If cFooter is not Character,
// the value will be formatted using column's picture
// cFooter can be a codeblock also
AEval( oBrw:aCols, { |oCol| oCol:oFooterFont := oBold } )
oBrw:MakeTotals()
oBrw:createFromCode()
oWnd:oClient := obrw
// Create ButtonBar
//BtnBar( oBrw ) // Commn ButtonBar for all sample Browses
// DEFINE BUTTON OF oWnd:oBar ;
// RESOURCE "EXPAND" TOP PROMPT "Expand ALL" ;
// ACTION ( oBrw:Expand(), oBrw:Refresh(), oBrw:SetFocus() )
//
// DEFINE BUTTON OF oWnd:oBar ;
// RESOURCE "COLLAPS" TOP PROMPT "Collapse ALL" ;
// ACTION ( oBrw:Collapse(), oBrw:Refresh(), oBrw:SetFocus() )
SET MESSAGE OF oWnd TO oWnd:cCaption 2007
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus() VALID (oRs:End(), .T.)
RETURN NIL
METHOD TestTree:TDolphinGetsummary
LOCAL oRs, csql
cSql := ;
"SELECT state,city, COUNT(*) AS EMPLOYEES, SUM(salary) AS totsalary " + ;
"FROM customer " + ;
"GROUP BY state, city " + ;
"UNION ALL " + ;
"SELECT state, '' AS city, employees, totsalary FROM " + ;
"(SELECT state, COUNT(*) AS employees, SUM(salary) AS totsalary " + ;
"FROM customer " + ;
"GROUP BY state ) t_b2 " + ;
"ORDER BY state, city "
IF ::oCon == NIL
::oCon = ::ConnectToDolphin()
ENDIF
IF ! ::oCon:lError
oRs = ::oCon:Query( cSql )
IF ::oCon:lError
MsgInfo('Access Table Open Failure')
RETURN NIL
ENDIF
ELSE
MsgInfo( "Access Connect Fail" )
ENDIF
RETURN oRs
METHOD TestTree:ConnectToDolphin()
LOCAL oCon
LOCAL cHost := "dolphintest.sitasoft.net"
LOCAL cUser := "test_dolphin"
LOCAL cPass := "123456"
LOCAL cDB := "dolphin_man"
oCon = TDolphinSrv():New( cHost, cUser, cPass, , , cDB )
RETURN oCon
METHOD TestTree:MakeTree( oRs, nMethod )
local oTree
local cState
oRs:GoTop()
TREE oTree
do while !oRs:Eof()
if oRs:state == cState
if nMethod == 1
_TreeItem( oRs:city ):Cargo := ;
{ oRs:employees, ;
oRs:totSalary ;
}
else
_TreeItem( Trim( oRs:city ) ):Cargo := oRs:RecNo()
endif
else
if cState != nil
ENDTREE
endif
if nMethod == 1
_TreeItem( oRs:state ):Cargo := ;
{ oRs:employees, ;
oRs:totSalary ;
}
else
_TreeItem( oRs:state ):Cargo := oRs:RecNo()
endif
cState := oRs:state
TREE
endif
oRs:Skip()
enddo
ENDTREE
ENDTREE
oRs:GoTop()
return oTree
METHOD TestTree:TDolphinGetTotals()
local oRs, csql
cSql := ;
"SELECT COUNT(*) AS employees, SUM(salary) AS totsalary FROM customer"
IF ! ::oCon:lError
oRs = ::oCon:Query( cSql )
IF ::oCon:lError
MsgInfo('Access Table Open Failure')
RETURN NIL
ENDIF
ELSE
MsgInfo( "Access Connect Fail" )
ENDIF
return oRsDaniel;
muchas gracias! (justo estaba rehaciendo un sample con la DATABASE Tdolphin)
Lo pruebo... (bue... no tengo dudas que que ahora si funcionará)
Saludos