Here is my PHP File
This handles the loading of the grid.
I hope this helps.
<?php
require("base_connector.php");
require("grid_connector.php");
require("form_connector.php");
require("options_connector.php");
require_once("config.php");
$res = mysql_connect($mysql_server,$mysql_user,$mysql_pass) or die(mysql_error());;
mysql_select_db($mysql_db,$res) or die(mysql_error());;
$database = $mysql_db;
$table = "company";
$sql = "SELECT * from ".$table;
$result = mysql_query($sql,$res);
$x = 0;
$flds = '';
$cols = '';
$head = '';
$hidden = '';
$type = '';
$align = '';
$filter = '';
$width = '80,';
$srt = '';
while ($property = mysql_fetch_field($result))
{
$cols = $cols.$property->name.',';
$flds = $flds.ucwords($property->name).',';
$hidden = $hidden.'false,';
if ($x == 0){$type = $type.'coro,';}
else {$type = $type.'co,';}
$align = $align.'left,';
$filter = $filter.'#connector_text_filter,';
$srt = $srt.'connector,';
if ($x == 2) { $width = $width.'*,';} else if ($x > 0) $width = $width.'100,';
$x++;
}
$cols = substr($cols,0,strlen($cols)-1);
$flds = substr($flds,0,strlen($flds)-1);
$hidden = substr($hidden,0,strlen($hidden)-1);
$type = substr($type,0,strlen($type)-1);
$align = substr($align,0,strlen($align)-1);
$filter = substr($filter,0,strlen($filter)-1);
$width = substr($width,0,strlen($width)-1);
$srt = substr($srt,0,strlen($srt)-1);
$head = $flds;
$grid = new GridConnector($res);
// $grid->enable_log("dhtmlxerrorLog",true);
$grid->dynamic_loading(true);
$grid->event->attach("beforeRender","formatImage");
$province = new OptionsConnector($res);
$country = new OptionsConnector($res);
$province->render_table("province","id","id(value), id(label)");
$country->render_table("country","id","id(value), id(label)");
$grid->set_options("province",$province);
$grid->set_options("country",$country);
// $grid->setHeader("Id,Name,Name,Salutation,Dept.,Address,City,Province,Country,Postal,Phone,Mobile,Email,Web,Company,Title,Notes,Profile");
$grid->setHeader($head);
$grid->setInitWidths($width);
$grid->setColSorting($srt);
$grid->setColTypes($type);
$grid->setColAlign($align);
$grid->attachHeader($filter);
$dhx_cols = '';
for ($l=0;$l<$x;$l++) {$dhx_cols = $dhx_cols.$l.',';}
$_GET["dhx_colls"]= substr($dhx_cols,0,strlen($dhx_cols)-1);
$grid->render_table($table,'code',$cols);
mysql_close($res);
function formatImage($row){
$data = $row->get_value('profile');
if (strpos($data,'image')){
$row->set_value("profile","");}
}
?>
Then I use grid.load(“filename.php”);
to load the grid.
Thanks
Rob