Hi ,
I am new to DhtmlGrid, I was trying load a grid by connecting to postgres sql server.
But grid is not getting populated and its not even throwing any error.When I invoke my Connector servlet its generating xml, but somehow its not getting loaded in grid, Please help me here…
Please find my code below:
index.html
SLPMS. Customer Manager /*these styles allow dhtmlxLayout to work in fullscreen mode in different browsers correctly*/ html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; background-color:white; }<script type="text/javascript">
var layout,menu,toolbar,contactsGrid,contactForm;
dhtmlx.image_path = "codebase/imgs/";
dhtmlxEvent(window,"load",function(){
layout = new dhtmlXLayoutObject(document.body,"2U");
layout.cells("a").setText("Customers");
layout.cells("b").setText(" Add Customer");
layout.cells("a").setWidth(700);
toolbar = layout.attachToolbar();
toolbar.setIconsPath("icons/");
toolbar.loadXML("codebase/xml/toolbar.xml");
contactsGrid = layout.cells("a").attachGrid();
//contactGrid.setImagePath("./codebase/imgs/");
//contactGrid.setSkin("dhx_skyblue");
contactsGrid.setHeader("Name,Address,Phone Number,Email,Reference,Date Of First Contact,Special Arrangements,Test Report Format Type");
contactsGrid.setInitWidths("*,*,*,*,*,*,*,*");
contactsGrid.setColAlign("left,left,left,left,left,left,left,left");
contactsGrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro");
//contactsGrid.setColSorting("str,str,str");
contactsGrid.init();
myGrid.load("/testGrid");
})
</script>
import java.sql.Connection;
import java.sql.DriverManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dhtmlx.connector.DBType;
import com.dhtmlx.connector.GridConnector;
import com.dhtmlx.connector.ThreadSafeConnectorServlet;
public class SaalsConnectorServlet extends ThreadSafeConnectorServlet{
@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
//obtain DB connection
Connection conn=null;
try {
Class.forName (“org.postgresql.Driver”).newInstance ();
conn = DriverManager.getConnection(“jdbc:postgresql://localhost:5432/SLPMS”, “postgres”, “admin”);
System.out.println(“Con:”+conn);
} catch (Throwable e) {
e.printStackTrace();
}
//Initialize connector
GridConnector c = new GridConnector(conn,DBType.PostgreSQL);
c.servlet(req, res);
//configure used table and fields
c.render_table("customer", "customerid", "name,address,phonenumber,email,reference,dateoffirstcontact,specialarrangements");
}
}