MariaDB RS Tree

MariaDB RS Tree

Postby fraxzi » Sat Aug 11, 2018 2:15 am

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
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: MariaDB RS Tree

Postby nageswaragunupudi » Sun Aug 12, 2018 8:28 am

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  Expand view
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
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MariaDB RS Tree

Postby fraxzi » Mon Aug 13, 2018 12:04 am

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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

MariaDB RS Tree and Sub Total

Postby shri_fwh » Sat Apr 20, 2019 3:45 pm

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
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: MariaDB RS Tree and Sub Total

Postby nageswaragunupudi » Sun Apr 21, 2019 4:01 pm

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  Expand view
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
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MariaDB RS Tree

Postby Marc Venken » Mon Apr 22, 2019 11:39 am

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 : viewtopic.php?f=3&t=29853&hilit=tree+with+dbf
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests