Recd
I will get back to you
Mr. Rao, refresh a Tree
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mr. Rao, refresh a Tree
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Mr. Rao, refresh a Tree
Mr. Rao.
Ok
Thanks for your effort
Ok
Thanks for your effort
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mr. Rao, refresh a Tree
When you edit and modify the value of the field "PAR_DES", then you should also change the prompt of treeitem also like this:
Code: Select all | Expand
oBrw:oTreeItem:SetText( cNewValue )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Mr. Rao, refresh a Tree
Mr. Rao:
Perfect !
now what should I do to refresh a new branch?
Regards
Perfect !
now what should I do to refresh a new branch?
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mr. Rao, refresh a Tree
This is a sample code. Still this does not support Append or Delete.
I will show that in my next sample.
I suggest this way of edit dialogs.
Please build and run this sample as it is.
In particular, please observe how to simplify the Edit Dialog and how to save changes.
Next we will see how to implement Append and Delete also.
I will show that in my next sample.
I suggest this way of edit dialogs.
Code: Select all | Expand
#include "fivewin.ch"
#include "dbcombo.ch"
static oMarcas, oModelos
function Main()
local oCn, oRs, cSql
local oDlg, oBrw, oFont
FWNumFormat( "A", .t. )
SetGetColorFocus()
MsgRun( "Connecting", "FW Clould Server", { || ;
oCn := maria_Connect( "209.250.245.152,fwh,fwhuser,FiveTech@2022", .t. ) } )
if oCn == nil; return nil; endif
oCn:lShowErrors := .t.
TEXT INTO cSql
SELECT A.*, B.MAR_DES, C.MOD_DES
FROM partes A
LEFT JOIN marcas B ON A.PAR_MAR = B.MAR_NUM
LEFT JOIN modelos C ON A.PAR_MAR = C.MOD_MAR AND A.PAR_MOD = C.MOD_COD
ORDER BY PAR_MAR,PAR_MOD,PAR_COD
ENDTEXT
oMarcas := oCn:RowSet( "marcas" )
oModelos := oCn:RowSet( "modelos" )
MsgRun( "Opening table", "partes", { || ;
oRs := oCn:RowSet( cSql ) } )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont RESIZABLE
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs ;
COLUMNS "MAR_DES","MOD_DES","PAR_DES","PAR_COD";
HEADERS "Marca","Modelo","Nombre o descripción","Código";
CELL LINES NOBORDER
WITH OBJECT oBrw
:nStretchCol := 1
:SetTree( 3 )
:oTree:OpenAll()
:lDisplayZeros := .f.
:bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:oTree == nil, CLR_WHITE, CLR_YELLOW ) } }
:bEdit := { |oRec| Editar( oRec ) }
:blDblClick := { || oBrw:EditSource() }
:bKeyDown := { |nKey| IIF(nKey == VK_RETURN, oBrw:EditSource(), ) }
:bChange := { || oDlg:AEvalWhen() }
:CreateFromCode()
END
@ 10, 20 BUTTON "ADD" SIZE 100,40 PIXEL OF oDlg ACTION MsgInfo( "Not implemented" ) ;
WHEN Empty( oBrw:oTreeItem:oTree )
@ 10,140 BUTTON "EDIT" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource() ;
WHEN oBrw:oTreeItem:Cargo > 0
@ 10,260 BUTTON "Delete" SIZE 100,40 PIXEL OF oDlg ACTION MsgInfo( "Not implemented" ) ;
WHEN Empty( oBrw:oTreeItem:oTree )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oRs:Close()
oCn:Close()
return nil
function Editar( oRec ) // oRec is FW_Record Object
local lAppend := ( oRec:RecNo == 0 )
local oBrw := oRec:oBrw
local oTreeItem := oBrw:oTreeItem
local oDlg, oCbx1, oCbx2
if lAppend
? "append not implemented"
return nil
endif
oRec:bOnSave := { || oTreeItem:cPrompt := oRec:par_des }
DEFINE DIALOG oDlg SIZE 400,180 PIXEL TRUEPIXEL
@ 22, 20 SAY "MAR_DES" SIZE 60,24 PIXEL OF oDlg
@ 20, 90 DBCOMBO oCbx1 VAR oRec:par_mar SIZE 200,24 PIXEL OF oDlg ;
ALIAS oMarcas ITEMFIELD "MAR_NUM" LISTFIELD "MAR_DES" ;
WHEN lAppend
@ 52, 20 SAY "MOD_DES" SIZE 60,24 PIXEL OF oDlg
@ 50, 90 DBCOMBO oCbx2 VAR oRec:par_mod SIZE 200,24 PIXEL OF oDlg ;
ALIAS oModelos ITEMFIELD "MOD_COD" LISTFIELD "MOD_DES" ;
WHEN lAppend
@ 80, 20 SAY "PAR_DES" GET oRec:par_des SIZE 340,24 PIXEL OF oDlg
@ 120, 20 BUTTON "SAVE" SIZE 80,30 PIXEL OF oDlg ACTION ( oRec:Save() )
@ 120,140 BUTTON "CLOSE" SIZE 80,30 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
Please build and run this sample as it is.
In particular, please observe how to simplify the Edit Dialog and how to save changes.
Next we will see how to implement Append and Delete also.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mr. Rao, refresh a Tree
This improved sample provides ADD, EDIT and DELETE
Code: Select all | Expand
#include "fivewin.ch"
#include "dbcombo.ch"
REQUEST DBFCDX
static oMarcas, oModelos
function Main()
local oCn, oRs, cSql
local oDlg, oBrw, oFont, oTree
FWNumFormat( "A", .t. )
SetGetColorFocus()
MsgRun( "Connecting", "FW Clould Server", { || ;
oCn := maria_Connect( "209.250.245.152,fwh,fwhuser,FiveTech@2022", .t. ) } )
if oCn == nil; return nil; endif
oCn:lShowErrors := .t.
TEXT INTO cSql
SELECT A.*, B.MAR_DES, C.MOD_DES
FROM partes A
LEFT JOIN marcas B ON A.PAR_MAR = B.MAR_NUM
LEFT JOIN modelos C ON A.PAR_MAR = C.MOD_MAR AND A.PAR_MOD = C.MOD_COD
ORDER BY PAR_MAR,PAR_MOD,PAR_COD
ENDTEXT
oMarcas := oCn:RowSet( "marcas" )
oModelos := oCn:RowSet( "modelos" )
MsgRun( "Opening table", "partes", { || ;
oRs := oCn:RowSet( cSql ) } )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,600 PIXEL TRUEPIXEL FONT oFont RESIZABLE
@ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oRs ;
COLUMNS "MAR_DES","MOD_DES","PAR_DES","PAR_COD";
HEADERS "Marca","Modelo","Nombre o descripción","Código";
CELL LINES NOBORDER
WITH OBJECT oBrw
:nStretchCol := 1
:SetTree( 3 )
:oTree:OpenAll()
:lDisplayZeros := .f.
:bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:oTree == nil, CLR_WHITE, CLR_YELLOW ) } }
:bEdit := { |oRec| Editar( oRec ) }
:blDblClick := { || oBrw:EditSource() }
:bKeyDown := { |nKey| IIF(nKey == VK_RETURN, oBrw:EditSource(), ) }
:bChange := { || oDlg:AEvalWhen() }
:CreateFromCode()
END
@ 10, 20 BUTTON "ADD" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource( .t. )
@ 10,140 BUTTON "EDIT" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource() ;
WHEN oBrw:oTreeItem:Cargo > 0
@ 10,260 BUTTON "Delete" SIZE 100,40 PIXEL OF oDlg ACTION ( ;
oBrw:Delete(), oBrw:oTreeItem:Delete(), oBrw:Refresh(), oBrw:Change() ) ;
WHEN oBrw:oTreeItem:Cargo > 0
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
oRs:Close()
oCn:Close()
return nil
function Editar( oRec ) // oRec is FW_Record Object
local lAppend := ( oRec:RecNo == 0 )
local oBrw := oRec:oBrw
local oTreeItem := oBrw:oTreeItem
local oDlg, oCbx1, oCbx2
if lAppend
oRec:bOnSave := { |oRec| OnAppend( oRec ), oDlg:End() }
else
oRec:bOnSave := { || oTreeItem:cPrompt := oRec:par_des }
endif
oRec:bValid := { |o| !( EMPTY( o:par_mar ) .or. EMPTY( o:par_mod ) .or. EMPTY( o:par_cod ) ) }
DEFINE DIALOG oDlg SIZE 400,220 PIXEL TRUEPIXEL
@ 22, 20 SAY "MAR_DES" SIZE 60,24 PIXEL OF oDlg
@ 20, 90 DBCOMBO oCbx1 VAR oRec:par_mar SIZE 200,24 PIXEL OF oDlg ;
ALIAS oMarcas ITEMFIELD "MAR_NUM" LISTFIELD "MAR_DES" ;
WHEN lAppend
oCbx1:bChange := <||
oModelos:Filter := "MOD_MAR=" + cValToChar( oRec:par_mar )
oModelos:MoveFirst()
oCbx2:Refill()
oCbx2:Refresh()
return .t.
>
@ 52, 20 SAY "MOD_DES" SIZE 60,24 PIXEL OF oDlg
@ 50, 90 DBCOMBO oCbx2 VAR oRec:par_mod SIZE 200,24 PIXEL OF oDlg ;
ALIAS oModelos ITEMFIELD "MOD_COD" LISTFIELD "MOD_DES" ;
WHEN lAppend
@ 80, 20 SAY "PAR_COD" GET oRec:par_cod SIZE 200,24 PIXEL OF oDlg
@ 110, 20 SAY "PAR_DES" GET oRec:par_des SIZE 340,24 PIXEL OF oDlg
@ 160, 20 BUTTON "SAVE" SIZE 80,30 PIXEL OF oDlg ACTION oRec:Save( .t. ) ;
WHEN oRec:Modified()
@ 160,140 BUTTON "CLOSE" SIZE 80,30 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
static function OnAppend( oRec )
local nNewRec := oRec:RecNo
local oBrw := oRec:oBrw
local oRs := oBrw:uDataSource
local oTree, nLen, oItem
local aBlocks := { { || oRs:Fields( "MAR_DES" ):Value }, ;
{ || oRs:Fields( "MOD_DES" ):Value }, ;
{ || oRs:Fields( "PAR_DES" ):Value } }
oRs:ReQuery()
oRs:Sort := "PAR_MAR,PAR_MOD,PAR_COD"
oRs:MoveFirst()
nLen := oRs:RecordCount()
oTree := SummaryDataAsTree( ;
{ || oRs:Move( 1 ) }, { |nRow| nRow > nLen }, aBlocks, { || oRs:BookMark } )
oTree:OpenAll()
oBrw:oTree := oTree
oBrw:GoTop()
oBrw:Refresh()
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Mr. Rao, refresh a Tree
Mr. Rao:
Thanks, I'll try it.
Regards
Thanks, I'll try it.
Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero