Hi there,
I am trying to work with the jqGrid for PHP.
In my SiteController index:
public function actionIndex() {
$conn = new PDO ( DB_DSN, DB_USER, DB_PASSWORD );
$conn->query ( "SET NAMES utf8" );
// Create the jqGrid instance
$grid = new jqGridRender ( $conn );
// Write the SQL Query
$grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel ();
// renders the view file 'protected/views/site/index.php'
$grid->setUrl('myfirstgrid.php');
$grid->setGridOptions ( array ("caption" => "This is custom Caption", "rowNum" => 10, "sortname" => "OrderID", "hoverrows" => true, "rowList" => array (10, 20, 50 ) ) );
// Change some property of the field(s)
$grid->setColProperty ( "OrderID", array ("label" => "ID", "width" => 60 ) );
$grid->setColProperty ( "OrderDate", array ("formatter" => "date", "formatoptions" => array ("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y" ) ) );
// Enjoy
$grid->renderGrid ( '#grid', '#pager', true, null, null, true, true );
$conn = null;
// using the default layout 'protected/views/layouts/main.php'
$this->render ( 'index', $grid );
}
In my index view-file, doing print_r($data) gives me the result of the table. How can I render the data so that it will be in the expected result, which is in grid format?