Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Appu on Oct 13, 2008 03:13
open dhtmlx forum
DHTMLXGRID

Hi All,

Thanks a lot for your response.

I have made changes as per your suggestions. And the error got cleared. But the web page is loaded with empty dataset. I cross-checked all databse settings. I am attaching my dataValue.js file. Can you give me a solution...?

<%@ page import = "java.sql.*" %>

<%

    String db_ipp_addr = "localhost";

    String db_username = "root";

    String db_password = "root";

    String db_name = "myDB";

    // set content type and xml tag

    response.setContentType("text/xml");

    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

    // define variables from incoming values

    String posStart = "";

    if (request.getParameter("posStart") != null){

        posStart = request.getParameter("posStart");

    }else{

        posStart = "0";

    }   

    String count = "";

    if (request.getParameter("count") != null){

        count = request.getParameter("count");

    }else{

        count = "100";   

    }   

    Connection connection = null;

    Statement statement = null;

    ResultSet rs = null;

    String connectionURL = "jdbc:mysql://" + db_ipp_addr + ":3306/" + db_name;

    Class.forName("com.mysql.jdbc.Driver").newInstance();

    connection = DriverManager.getConnection(connectionURL, db_username, db_password);

    // query to products table

    String sql = "SELECT  * FROM USER_MST";

   // if this is the first query - get total number of records in the query result

    String totalCount = "";

    if (posStart.equals("0")){

        String sqlCount = "Select count(*) as cnt from (" + sql + ") as tbl";

        statement = connection.createStatement();

        rs = statement.executeQuery(sqlCount);

        rs.next();

        totalCount = rs.getString("cnt");

        rs.close();

    } else {

        totalCount = "";

    }

    // add limits to query to get only rows necessary for output

    sql += " LIMIT " + posStart + "," + count;

    // Execute the query

    statement = connection.createStatement();

    rs = statement.executeQuery(sql);  

    // output data in XML format  

    out.println("<rows total_count='" + totalCount + "' pos='" + posStart + "'>");

    while (rs.next()) {

        out.println("<row id='" + rs.getString("USERID") + "'>");

            out.println("<cell>");

            out.println(rs.getString("USERNAME")); 

            out.println("</cell>");

            out.println("<cell>");

            out.println(rs.getString("CHAR_USERID"));

            out.println("</cell>");

            out.println("<cell>");

            out.println(rs.getString("MANGER_ID")); 

            out.println("</cell>");

        out.println("</row>");

    }

    out.write("</rows>");

    rs.close();

%>

Answer posted by Support on Oct 13, 2008 03:53
Which format you are using for data loading, based on your initial code (dataValue.js) , I thinked about javascript, but you are generating XML in your server side code?

If you are using XML code, revert back to previous syntax.

mygrid.loadXML(gridQString );

and check next 
 - data which outputed in XML provided in UTF encoding ( if it has high ASCII characters , xml will be treated as incorrect one )
 - data must not contain < > & ( you need to use CDATA sections , if you need to sent info with such special chars )
 - I'm not pretty sure, but your xml may not load correctly in FF, because of empty line before <?xml declaration

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob