Unifosys Business Engineering Support
June 25, 2018 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: March 11, 2015: Chart4.NET 2015 (5.1) supports large organization charts, PDF Rendering (Desktop/ASP.NET), 3D, Planer views, Navigational Tree and Data Search:
http://unifosys.com/support/index.php?topic=105.0
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Create Organization Chart from Database/ODBC  (Read 5067 times)
admin1
Guest
« on: January 21, 2011 »

Update:


You can download database sample source code from the following links:

Winform:
http://unifosys.com/hierarchy-chart/Create_Organization_Chart_From_Database_Sample.html

Webform Demo & Downloads:
http://organization.unifosys.com/Create_Organization_Chart_From_Database_Sample_WebForm.aspx






N.B: The explanation here is based on Microsoft SQL Server, but equally applies to any DBMS through Open Database Connectivity.

Refer the following link for sample table and sample data:
http://unifosys.com/chart4.net/html/T_UnifoChart_Hierarchy_HierarchyData.htm

1. First you should create a database named 'test' in MSSQL Server.
2. Then run the sample SQL script (See link above) against the database to create the sample table.
3. Open the table in MSSQL Management Studio and paste the sample data (See link above).
4. Test database connection. For that download source code of the online demo from the following link: http://organization.unifosys.com/demo.aspx
5. Replace the code in heHierarchyData event in the sample source code as follows (You connection-string may vary according to your configuration):

        protected void HierarchyWeb1_heHierarchyData( object sender, EventArgs e )
        {
            System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection( );
            conn.ConnectionString = "Driver={SQL Server};Server=.\\SQLEXPRESS;Database=test1;Trusted_Connection=Yes;";
            //Check sResult for any errors
            string sResult = HierarchyWeb1.hpcData.LoadFromDatabase(
                    conn, "Parc", "id", "pid", "txt", "", "", "tooltip", "imagefile" );
            HierarchyWeb1.hpcData.ExpandAll( );//expand all nodes
        }


N.B:
  • Please check sResult variable to get a clue, if there is any connection error.
  • You have to provide data in the heHierarchyData event itself. For that, please do any one of the following:
    1. Download the online sample source code and just replace HierarchyWeb1_heHierarchyData() with the above mentioned code.
    OR
    2. If you are making a fresh page/site/application, link the event handler to this function, either by typing in the aspx page (bold thing below) or through Visual Studio designer.

           <cc1:HierarchyWeb ID="HierarchyWeb1" runat="server" Height="400px" OnheHierarchyDraw="HierarchyWeb1_heHierarchyDraw"
                Style="z-index: 101; left: 10%; position: relative;" Text="MK" Width="700px" OnInit="HierarchyWeb1_Init" OnheHierarchyData="HierarchyWeb1_heHierarchyData"/>


  • For winforms, it can be in any event including Form_Load, but do a HierarchyWin1.Refresh(), if it is inside a button event for example.
« Last Edit: May 25, 2011 by Admin » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
© 2013 www.unifosys.com