Mr. Rao Pls your help

Post Reply
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Mr. Rao Pls your help

Post by Armando »

Hi. Mr. Rao:

Would you help us, we need make a tree in a xBrowse, this is our
code but it does not show us the records, why?

Code: Select all

#include "fivewin.ch"
#Include "Ado.ch"

FUNCTION TestTree()
   LOCAL oRsLoc, oDlg, oFont, oBrw

   oRsLoc := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
                                          "* " +;
                                       "FROM " +;
                                          "Locales ",;
                                       "ORDER BY " +;
                                          "LOC_CAL,LOC_LOC",adLockOptimistic,adOpenDynamic,0)

   oRsLoc:MoveFirst()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
    DEFINE DIALOG oDlg RESOURCE "TestTree"

        REDEFINE XBROWSE oBrw ID 200 OF oDlg;
            DATASOURCE oRsLoc;
            COLUMNS "LOC_CAL","LOC_LOC","LOC_GAS","LOC_LUZ","LOC_AGU","LOC_REN";
            HEADERS "Calle/Local","Local","Gastos","Luz","Agua","Arriendo";
         CELL LINES NOBORDER

         WITH OBJECT oBrw
            :SetTree( 2 )
            :oTree:OpenAll()
            :lDisplayZeros := .f.
         END

   ACTIVATE DIALOG oDlg CENTERED
   oFont:END()
RETURN(NIL)
 
With best 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Mr. Rao Pls your help

Post by nageswaragunupudi »

This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.
Regards

G. N. Rao.
Hyderabad, India
User avatar
richard-service
Posts: 583
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan
Contact:

Re: Mr. Rao Pls your help

Post by richard-service »

nageswaragunupudi wrote:This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.
Dear Mr.Rao

How about use TMySQL? Compatible?
Regards,

Richard

Harbour 3.2.0dev (r1904111533)/xHarbour 1.2.3 Intl. (SimpLex) (Build 20180818) => Borland C++ v7.4
xHarbour 0.99.71 (SimpLex) => Borland C++ v5.5
MySQL v5.7 /ADS v12
Harbour 3.2.0dev (r1603181642) => Borland C++ v7.4 64bit
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Mr. Rao Pls your help

Post by Armando »

Mr. Rao:

Don't worry, take your time.

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
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Mr. Rao Pls your help

Post by Armando »

Mr. Richard:

I'm afraid not yet.

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Mr. Rao Pls your help

Post by nageswaragunupudi »

richard-service wrote:
nageswaragunupudi wrote:This seems to be working with DBF but not ADO.
We are looking into it and will come back to you.
Please give us a little time.
Dear Mr.Rao

How about use TMySQL? Compatible?
It should work with TMySql as it is.
It worked for me with FWH built-in MySql library.
This is my test.

Code: Select all

   oCn := maria_Connect( "localhost,fwh,root,password" )
   oRs := oCn:RowSet( "select * from customer order by state,city" )

   DEFINE DIALOG oDlg SIZE 800,600 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "STATE", "CITY", "FIRST", "SALARY" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:SetTree( 2 )
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED //ON INIT oBrw:SetTree( 2 )
 
Please try with TMySql and let us know.
You need to use "ORDERBY fld1, fld2" in your query and then use the same fld1,fld2 as the first two fields in xBrowse.

Problem is only with ADO.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Mr. Rao Pls your help

Post by Armando »

Mr. Rao:

Many thanks, I don't use TMySql at all. Just FWH, MySQL & ADO. :cry:

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Mr. Rao Pls your help

Post by nageswaragunupudi »

My reply about TMySql was intended for Mr. Richard.
Regards

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

Re: Mr. Rao Pls your help

Post by nageswaragunupudi »

The facility to convert a normal browse of ordered data into a Tree browse by calling oBrw:SetTree( nLevels, [aBitmaps] ) is working in case of datasources, which accept GOTO( 0 ) (similar to :BookMark := 0) and when Eof() returns blank values for fields. So, this is working with DBF, RowSets, Arrays, etc, but not with ADO.

Setting oRs:Bookmark := 0.0 errors out and when oRs:Eof() we can not access any field values.

For this reason, we need to modify xbrowse to handle ADO recordsets. These modifications are made in FWH 21.01.

We publish here the changes you can make to xbrowse.prg to make it work for ADO recordsets.

1) Please locate this line of code in the method SetTree(...) (line 7790 in FWH 2012)

Code: Select all

      bOnSkip     := { || Eval( bBookMark, ::oTreeItem:cargo ) }
 
Please replace this single line code with the following code:

Code: Select all

      if lAnd( ::nDataType, DATATYPE_ADO )
         bOnSkip     := { || If( Empty( ::oTreeItem:Cargo ),,Eval( bBookMark, ::oTreeItem:cargo ) ) }
         AEval( ::aCols, { |o| AdoTreeBlocks( o ) }, nLevels + 1 )
      else
         bOnSkip     := { || Eval( bBookMark, ::oTreeItem:cargo ) }
      endif
 
After making this change, add this static function anywhere in the xbrowse.prg.

Code: Select all

static function AdoTreeBlocks( oCol )

   local bEditValue  := oCol:bEditValue
   local oBrw        := oCol:oBrw

   oCol:bEditValue := { |x,o| If( Empty( oBrw:oTreeItem:Cargo ), ;
                              uValBlank( Eval( bEditValue ) ), ;
                              Eval( bEditValue, x, o ) ) }


return nil
 
With these two changes, your application code will work as expected.
Regards

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

Re: Mr. Rao Pls your help

Post by nageswaragunupudi »

We discussed how to convert a normal browse of ordered data into a tree-browse at runtime. This is provided as an extra feature.

Still, the normal and standard way is to first create a tree object from the data and then browse the tree object.

Here is an example:

Code: Select all

#include "fivewin.ch"

function Main()

   local oCn, oRs, oTree, tmp
   local oDlg, oBrw

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   if oCn == nil
      return nil
   endif
   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM CUSTOMER ORDER BY STATE,CITY,FIRST" )

   oRs:MoveFirst()
   TREE oTree
      do while !oRs:Eof()
         TREEITEM oRs:Fields( "state" ):Value ;
            CARGO { uValBlank( oRs:Fields( "first" ):Value ), uValBlank( oRs:Fields( "salary" ):Value ) }
         tmp := oRs:Fields( "state" ):Value
         TREE
         do while !oRs:Eof() .and. oRs:Fields( "state" ):Value == tmp
            TREEITEM oRs:Fields( "city" ):Value CARGO { oRs:Fields( "first" ):Value, oRs:Fields( "salary" ):Value }
            oRs:MoveNext()
         enddo
         ENDTREE
      enddo
   ENDTREE
   oRs:MoveFirst()
   oTree:OpenAll()

   DEFINE DIALOG oDlg SIZE 550,600 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oTree COLUMNS 1, 2 ;
      HEADERS "STATE>CITY", "FIRST", "SALARY" ;
      CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil
 
Image
Regards

G. N. Rao.
Hyderabad, India
Post Reply