MariaDB RS Tree

Post Reply
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

MariaDB RS Tree

Post by fraxzi »

Hi All,

It's been helpful Mr. Rao providing great help on oRS Tree issues (not only that of-course) :D

can anyone help creating this Tree using oRS-Parent-Child? where in the child sync when tree item expanded... :?: :?: :?:

Image

:?:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: MariaDB RS Tree

Post by nageswaragunupudi »

Do not open different rowsets. Open a single rowset with an sql statement joining all the tables.

This is a simple example. In real situation, you can nest the joins to the desired level.

Code: Select all

function TestTree2()

   local oCn
   local cSql, oRs, oDlg, oFont, oBrw

   oCn   := FW_DemoDB()

TEXT INTO cSql
   SELECT S.name AS StateName, C.city AS City, C.first AS Customer
   FROM states S
   LEFT JOIN customer C ON S.code = C.state
   ORDER BY StateName, City, Customer
ENDTEXT

   oRs   := oCn:RowSet( cSql )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
      COLUMNS "TRIM( StateName ) AS StateName", ;
              "TRIM( City )      AS City",      ;
              "TRIM( Customer )  AS Customer"   ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED  ;
      ON INIT oBrw:SetTree( 3, { 0x30082, 0x30084, 0x20097 } )
   RELEASE FONT oFont

   oCn:Close()

return nil
 
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: MariaDB RS Tree

Post by fraxzi »

Mr. Rao,

This is great approach.. I did it with JOINS too.. I thought of On-The-Fly oChild when parent root expanded.. But maybe not a good idea?

I always referenced your sample relative to xBrowse.. Absolutely very helpful. :wink:


:idea:
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
shri_fwh
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

MariaDB RS Tree and Sub Total

Post by shri_fwh »

Dear Rao Sir,

I need to show subtotal in XBROWSE on the Tree Level. Could you please help me for the same.

Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: MariaDB RS Tree and Sub Total

Post by nageswaragunupudi »

shri_fwh wrote:Dear Rao Sir,

I need to show subtotal in XBROWSE on the Tree Level. Could you please help me for the same.

Thanks
Shridhar
Please try this sample

Code: Select all

function TestTree2()

   local oCn
   local cSql, oRs, oDlg, oFont, oBrw, aSum

   FWNumFormat( "I", .t. )

   oCn   := FW_DemoDB()
   oCn:lShowErrors := .t.

TEXT INTO cSql
   SELECT State,City,AvgAge,TotalSalary FROM
   (
   SELECT state, city, AVG( age ) AS AvgAge, SUM( salary ) AS TotalSalary
   FROM customer
   WHERE state >= 'A' AND city >= 'A'
   GROUP BY state, city
   WITH ROLLUP
   ) C
   ORDER BY State,city
ENDTEXT

   oRs   := oCn:RowSet( cSql )
   aSum  := { oRs:Fields( "AvgAge" ):Value, oRs:Fields( "TotalSalary" ):Value }

   oRs:SetFilter( "state >= 'A'" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 480,500 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :AvgAge:cFooter      := aSum[ 1 ]
      :TotalSalary:cFooter := aSum[ 2 ]
      :AutoFit()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED  ;
      ON INIT ( ;
      oBrw:SetTree( 2, { FWDArrow(), FWRArrow() } ),   ;
      oBrw:bClrStds := { || { CLR_BLACK, If( oBrw:oTreeItem:nLevel == 1, 0x68DDFB, CLR_WHITE ) } } ;
      )
   RELEASE FONT oFont

   oCn:Close()

return nil
 
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: MariaDB RS Tree

Post by Marc Venken »

Mr. Rao,

I believe you also made a working sample for this with the use of Dbf. Have you that sample on your systems ? I can't find it.

Sorry, I found the sample

This is the link : http://forums.fivetechsupport.com/viewt ... e+with+dbf
Marc Venken
Using: FWH 20.08 with Harbour
Post Reply