No modifications on client side are required for regular data loading. In other cases you should include the connector.js file (located in dhtmlxConnector_java/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.do");
To perform insert/update/delete operations you should add dhtmlxDataProcessor (for more details about dhtmlxDataProcessor see related documentation):
myDP = new dataProcessor("myconnector.do"); myDP.init(myGrid);
On server side you need to 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.
After have implemented these operations you are ready to instantiate connector object. Only database connection link variable is mandatory parameter in all constructors. Optionally, you can specify database type
And as a last step - configuration, which fields and data will be used in connector
import java.sql.Connection; import java.sql.DriverManager; import com.dhtmlx.connector.*; /** * The Class BasicConnector. */ public class BasicConnector extends ConnectorServlet { @Override protected void configure() { //obtain DB connection Connection conn=null; try { Class.forName ("com.mysql.jdbc.Driver").newInstance (); conn = DriverManager.getConnection("jdbc:mysql://localhost/sampleDB", "root", ""); } catch (Throwable e) { e.printStackTrace(); } //Initialize connector GridConnector c = new GridConnector(conn); //configure used table and fields c.render_table("grid50000", "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