Hello All,
I have created a grid using the documentation that comes with the download. I was able to get the grid working on my Mac dev environment, but when I moved the files to my Windows 7 dev environment the grid started rendering without data.
I can use the same PDO object that is passed to the grid to do a var_dump and see that the data is accessed. The section below will display data:
$test = $conn->query(“SELECT VolunteerID, FirstName, LastName, PhoneNumber, Email FROM Volunteers”);
$data = $test->fetchAll();
var_dump($data);
But it looks like the grid itself is having problems:
require_once '../Grid/jq-config.php';
// include the jqGrid Class
require_once “../Grid/php/jqGrid.php”;
// include the PDO driver class
require_once “../Grid/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”);
$selectCommand = “SELECT VolunteerID, FirstName, LastName, PhoneNumber, Email FROM Volunteers”;
// Definition of the labels
$vLabels = array(“VolunteerID”=>”Id”,
“FirstName” => “First Name”,
“LastName” => “Last Name”,
“PhoneNumber” => “Phone Number”,
“Email” => “Email”);
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = $selectCommand;
// set the ouput format to json
$grid->dataType = “json”;
// Let the grid create the model
$grid->setColModel(null, null, $vLabels);
// point to Fright column to use the function named MyFormatter
$grid->setColProperty(“VolunteerID”, array(“formatter” => “js:volunteerIDFormatter”));
// Write the MyFormatter function
$myformat = << function volunteerIDFormatter (cellValue, options, rowdata) { var path = “VolunteerEdit.php”; var qStr = “?VolunteerID=” + cellValue; var cellHtml = “edit“; return cellHtml; } FORMATVOLUNTEERID; // Output the function with setJSCode $grid->setJSCode($myformat); // Set the url from where we obtain the data $grid->setUrl('VolunteerListGrid.php'); // Set grid caption using the option caption $grid->setGridOptions(array( “caption”=>”Volunteers”, “rowNum”=>10, “sortname”=>”VolunteerID”, “hoverrows”=>true, “rowList”=>array(10,20,50) )); // Change some property of the field(s) $grid->setColProperty(“VolunteerID”, array(“label”=>”ID”, “width”=>60)); // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?> Any recommendations/help you guys can offer will be appreciated! Thanks, Jeremy
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top