Codice PHP:
<?php
require_once 'jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqAutocomplete.php";
require_once ABSPATH."php/jqCalendar.php";
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
//$grid->SelectCommand = 'SELECT animals.id, animals.description, animals.animal_id, languages.description FROM animals, languages WHERE animals.language_id=languages.id ';
//$grid->SelectCommand = 'SELECT drugs.id, drugs.name, drugs.cod, companies.description, nations.description, activeingredient.description, posologies.description FROM drugs, companies, nations, activeingredient, posologies WHERE animals.language_id=languages.id ';
$grid->SelectCommand = 'SELECT apparaties.id, apparaties.description, languages.description FROM apparaties INNER JOIN languages ON languages.id = apparaties.language_id';
// set the ouput format to json
$grid->table = 'apparaties';
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('apparaties_grid.php');
// Set some grid options
$grid->setGridOptions(array("rowNum"=>10,"rowList"=>array(10,20,30),"sortname"=>"id"));
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
// Set in grid options scroll to 1
//$grid->setGridOptions(array("scroll"=>1,"rowNum"=>100,"sortname"=>"id","height"=>200));
// Change some property of the field(s)
$grid->setColProperty("id", array("width"=>80));
$grid->setColProperty("hire_date", array(
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y")
)
);
$grid->navigator = true;
//navigator
$grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>false, "search"=>false));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
<?php
require_once 'jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqAutocomplete.php";
require_once ABSPATH."php/jqCalendar.php";
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT apparaties.id, apparaties.description, languages.description FROM apparaties INNER JOIN languages ON languages.id = apparaties.language_id';
// set the ouput format to json
$grid->table = 'apparaties';
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('apparaties_grid.php');
// Set some grid options
$grid->setGridOptions(array("rowNum"=>10,"rowList"=>array(10,20,30),"sortname"=>"id"));
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
// Set in grid options scroll to 1
//$grid->setGridOptions(array("scroll"=>1,"rowNum"=>100,"sortname"=>"id","height"=>200));
// Change some property of the field(s)
$grid->setColProperty("id", array("width"=>80));
$grid->setColProperty("hire_date", array(
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y")
)
);
$grid->navigator = true;
//navigator
$grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>false, "search"=>false));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
questo è il codice del file grid.php