DHTMLX Docs & Samples Explorer

Index
dhtmlxconnector
Initialization of dhtmlxConnector

## Initialization of dhtmlxConnector

### Client Side Code

No modifications on client side are required for regular data loading. In other cases you should include the connector.js file (located in dhtmlxConnector_php/codebase) into your page. To perform any update operations you have to use dhtmlxDataProcessor, which has been already included in both Professional and Standard editions of dhtmlx library.

For data loading you need to point load (or loadXML) method of dhtmlx component to connector file:

            myGrid = new dhtmlXGridObject("pObjId");
            //... grid configuration commands
            myGrid.load("myconnector.php");

To perform insert/update/delete operations you should add dhtmlxDataProcessor (for more details about dhtmlxDataProcessor see related documentation):

            myDP = new dataProcessor("myconnector.php");
            myDP.init(myGrid);

Client side initialization for Tree, TreeGrid, Combo

### Server Side Code

To start operating with dhtmlxConnector you should do the following:

- include appropriate connector file into the page (Here and after we'll use dhtmlxGrid connector for code samples. All differences between connectors of other components will be described additionally. When using sample code with appropriate components, all files or function names which contain component name “grid” should be changed to “tree”, “treegrid” or “combo” accordingly.)

            require("connector/grid_connector.php");

- create Database connection

            $res=mysql_connect("localhost","root","");
            mysql_select_db("myDatabase");

After have implemented these operations you are ready to instantiate connector object. The only database connection link variable is mandatory parameter in all constructors. Optionally, you can specify database type (“MySQL” by default. Other possible: “Postgre”)

           $gridConn = new GridConnector($res,"MySQL");

And as a last step - configuration, which fields and data will be used in connector

            $gridConn->render_table("mytable","item_id","item_nm,item_cd");

This is all.

Above code must be enough to show data in component and sync update|delete|create operations from the component to the DB.

Server side initialization for other components and DB types