Solved

dhtmlx grid - populate with MySQL

Posted on 2014-01-20
5
1,442 Views
Last Modified: 2014-02-03
I am having trouble using the dhtmlx grid:  http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:toc

I am looking for someone who has used it with MySQL.  I have gotten closer to where I can get the column headers to display, but no data.

When I open gridData.php directly I get:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<rows>
<head>
<column type="ro" width="100">Dealer</column>
<column type="ro" width="100">Web Appts</column>
<column type="ro" width="100">Show Rate</column>
<column type="ro" width="100">Total Appt Set</column>
<column type="ro" width="100">Web Show #</column>
<column type="ro" width="100">Total RO $</column>
<column type="ro" width="100">Market</column>
<column type="ro" width="100">Period</column>
<settings>
<colwidth>px</colwidth>
</settings>
</head>
<row id="1390272345x0">
<cell>
<![CDATA[ Toyota Town ]]>
</cell>
<cell>
<![CDATA[ 110 ]]>
</cell>
<cell>
<![CDATA[ 55.7 ]]>
</cell>
<cell>
<![CDATA[ 201 ]]>
</cell>
<cell>
<![CDATA[ 56 ]]>
</cell>
<cell>
<![CDATA[ 173943 ]]>
</cell>
<cell>
<![CDATA[ WE1 ]]>
</cell>
<cell>
<![CDATA[ 01/2013 ]]>
</cell>
</row>

Open in new window


here is my gridData.php
<?php
require_once('config.php'); 
require("dhtmlxGrid/dhtmlxConnector/codebase/grid_config.php");// connector file
require("dhtmlxGrid/dhtmlxConnector/codebase/grid_connector.php");// connector file

//get fields to display on grid
    $fields="";
    $delim = "";
    $sql = "SELECT * FROM selectedfields ORDER BY sortOrder" ;
    $res = mysql_query($sql);
    if (!$res) die( mysql_error() );
    while($row = mysql_fetch_assoc($res))
    {
        $fields .= $delim .  $row["fieldName"]  ;
        $delim = ",";
    }            

$gridConn = new GridConnector($db_connection,"MySQL"); // connector object;    parameters: db connection and the type of the using db
$gridConn->set_config(new GridConfiguration());
$gridConn->render_table("dealerdata","",$fields,"");// data configuration 
 
 
?>

Open in new window


and here is my page to display the grid (displayData.php)
<html>
  <head>
     <link rel="STYLESHEET" type="text/css" href="dhtmlxGrid/codebase/dhtmlxgrid.css">
     <script src="dhtmlxGrid/dhtmlxConnector/codebase/connector.js"></script>
     <script src="dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
     <script src="dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
     <script src="dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
     <script>
        var mygrid;
        function doInitGrid(){
            mygrid = new dhtmlXGridObject('mygrid_container');
            //mygrid.setHeader("Name,Last Name,Department");//specifies the grid's headers
            mygrid.setImagePath("codebase/imgs/");
            mygrid.setSkin("light");
            mygrid.init();
            mygrid.load("gridData.php");
        }
     </script>
  </head>
  <body onload="doInitGrid()">
        <div id="mygrid_container"></div>
  </body>
</html>

Open in new window


Again, in displayData.php I am only getting the column headings, no data is displaying.

Thanks in advance for your help.
0
Comment
Question by:KCTechNet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 39807077
I'd suggest following the example here: http://docs.dhtmlx.com/doku.php?id=dhtmlxdatastore:datastore_example_server-side

I don't think you are setting up your connector correctly.
0
 

Author Comment

by:KCTechNet
ID: 39827069
that example is using the dataStore.  I just need the dataGrid and it looks like  I just need the connector since I don't need the data to be edited.  

I am using http://docs.dhtmlx.com/doku.php?id=tutorials:dhtmlxgrid_serverside for help, but I am just not seeing what I am doing wrong.
0
 

Author Comment

by:KCTechNet
ID: 39827153
Or if there is another free grid that others have had experience with I don't mind trying something else.
0
 

Author Comment

by:KCTechNet
ID: 39828319
currently checking out trirand's product:  http://www.trirand.net/demo/php/jqgrid/

hope to get that working because it seems pretty flexible and easy to configure.
0
 

Author Comment

by:KCTechNet
ID: 39831478
i was able to get Trirand's product to work.  Thanks for your time
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question