Hello,
i have some troubles to load data in my grid from DB with php connector.
I follow this tutorial [url]Start DHTMLX Docs*
But i have no idea why it doesn’t work like in the example.
index.html
[code]
Tableau avec Grid <link rel="STYLESHEET" type="text/css" href="dhtmlConnector/codebase/dhtmlx.css">
<script src="../codebase/dhtmlx.js"></script>
<script type="text/javascript" src="dhtmlxConnector/codebase/connector/connector.js"></script>
<link rel="STYLESHEET" type="text/css" href="dhtmlxGrid/dhtmlxGrid/codebase/dhtmlxgrid.css">
<script src="dhtmlxGrid/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script src="dhtmlxGrid/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script src="dhtmlxGrid/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script src="dhtmlxGrid/dhtmlxGrid/codebase/ext/dhtmlxgrid_export.js"></script>
<script>
var mygrid;
function doInitGrid(){
// creates a grid instance
mygrid = new dhtmlXGridObject('mygrid_container');
// sets the path to the grid images
mygrid.setImagePath("dhtmlxGrid/dhtmlxGrid/codebase/imgs/");
// sets the headers of the columns
//var mygrid = new dhtmlXGridObject('box');// object constructor
mygrid.setHeader("ARTNUM,Test, Test2");//specifies the grid's headers
// sets the width of the columns; * - the column fills all the available space
// Regarder la personnalisation de skin
// Essayer de mettre le maximum de ligne dans une fonction pour éviter la répétition lors de création de tableaux
mygrid.setInitWidths("*,150,150");
// sets the horizontal alignment of the value in the columns
mygrid.setColAlign("left,right,right");
//mygrid.setColAlign(0,"left");
// sets the skin of the grid
mygrid.setSkin("light");
// sets the sorting criteria of the columns
mygrid.setColSorting("");
// sets the types of the columns
mygrid.setColTypes("ro");
// populates the grid with the data in XML format
mygrid.init();//initializes the grid
mygrid.load("php/data.php");//populates the grid with data from the DB
//---dataProcessor initialization
var mydp = new dataProcessor ("php/data.php");// object constructor. Here you should specify a connector file
mydp.init(mygrid);// initializes dataProcessor. As the parameter you should specify your grid
// adds a new row to the grid
function addRow(){
var newId = (new Date()).valueOf()
mygrid.addRow(newId,"",mygrid.getRowsNum())
mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);
}
// remove the selected row from the grid
function removeRow(){
var selId = mygrid.getSelectedId()
mygrid.deleteRow(selId);
}
}
</script>
Add Row
Remove Row
[/code]
data.php :
[code]<?php
require_once(“dhtmlxConnector/codebase/connector/grid_connector.php”);// includes the appropriate connector
$res=mysql_connect(“myhost”,“mylogin”,“mypassword”);//connects to a server that contains the desired DB
mysql_select_db(“i5_articles”);// connects to the DB. ‘tasks’ is the name of our DB
$conn = new GridConnector($res,“MySQL”);// connector initialization
if(!$res)
{
die(‘Connexion impossible:’ .mysql_error());
}
echo ‘Connecte correctement’;
$conn->render_table(“ART”);// data configuration */
echo “ok”;
?>[/code]
My DB is “i5_articles”. My Table is “ART” and i want to load the column “ARTNUM”.