// include the datepicker class require_once ABSPATH . "php/jqCalendar.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 OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders'; // set the ouput format to json $grid->dataType = 'json'; $grid->table = "orders"; $grid->setPrimaryKeyId("OrderID"); // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set grid caption using the option caption $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"))); $grid->setAutocomplete("ShipName", false, "SELECT DISTINCT ShipName FROM orders WHERE ShipName LIKE ? ORDER BY ShipName", null, true, true); $grid->setDatepicker('OrderDate', null, true, true); $grid->datearray = array('OrderDate'); // Enjoy $grid->navigator = true; $grid->setNavOptions('navigator', array("excel" => false)); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;
// 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 OrderID, OrderDate, CustomerID, ShipName, Freight FROM orders'; // Set output format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set some grid options $grid->setGridOptions(array("rowNum" => 10, "rowList" => array(10, 20, 30), "sortname" => "OrderID")); // Change some property of the field(s) $grid->setColProperty("OrderDate", array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y"))); $grid->setColProperty("ShipName", array("width" => "200")); // Enable navigator $grid->navigator = true; // Enable search // By default we have multiple search enabled $grid->setNavOptions('navigator', array("excel" => false, "add" => false, "edit" => false, "del" => false, "view" => false)); // In order to enable the more complex search we should set multipleGroup option // Also we need show query roo $grid->setNavOptions('search', array("multipleGroup" => true, "showQuery" => true)); // client side validation when search $grid->setColProperty('OrderID', array("searchrules" => array("required" => true, "number" => true, "minValue" => 10200))); $grid->setDatepicker('OrderDate'); // Enjoy $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;
// 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 EmployeeID, FirstName, LastName, BirthDate FROM employees'; // Set the table to where you add the data $grid->table = 'employees'; // Set output format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); $grid->setColProperty('EmployeeID', array("editable" => false)); $grid->setColProperty('BirthDate', array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "Y-m-d"))); // Set some grid options $grid->setUserTime("m/d/Y"); $grid->setDatepicker("BirthDate", array("buttonOnly" => false)); $grid->setGridOptions(array("rowNum" => 10, "rowList" => array(10, 20, 30), "sortname" => "EmployeeID")); // navigator first should be enabled $grid->navigator = true; $grid->setNavOptions('navigator', array("add" => false, "edit" => false, "excel" => false, "search" => false, "del" => false, "refresh" => false)); // and just enable the inline $grid->inlineNav = true; // disable editing - just adding $grid->inlineNavOptions('navigator', array("edit" => false)); $grid->callGridMethod("#grid", 'setFrozenColumns'); // Enjoy $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;
// set the ouput format to json $grid->dataType = 'json'; $grid->table = "orders"; $grid->setPrimaryKeyId("OrderID"); // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); $grid->cacheCount = true; // Set grid caption using the option caption $grid->setGridOptions(array("caption" => "This is custom Caption", "rowNum" => 10, "sortname" => "OrderID", "hoverrows" => true, "rowList" => array(10, 20, 50), "postData" => array("grid_recs" => 776))); // Change some property of the field(s) $grid->setColProperty("OrderID", array("label" => "ID", "width" => 60, "editable" => false)); $grid->setColProperty("OrderDate", array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y"))); $grid->setAutocomplete("CustomerID", false, "SELECT CustomerID, CompanyName FROM customers WHERE CompanyName LIKE ? ORDER BY CompanyName", null, true, true); $grid->setDatepicker("OrderDate", array("buttonOnly" => false)); $grid->datearray = array('OrderDate'); // Enjoy $grid->navigator = false; $onselrow = <<<ONSELROW function(rowid, selected) { \tif(rowid && rowid !== lastSelection) { \t\t\$("#grid").jqGrid('restoreRow', lastSelection); \t\t\$("#grid").jqGrid('editRow', rowid, true); \t\tlastSelection = rowid; \t} } ONSELROW; $grid->setGridEvent('onSelectRow', $onselrow); $grid->renderGrid('#grid', '#pager', true, null, null, true, true);
require_once ABSPATH . "php/jqCalendar.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 OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders'; // set the ouput format to json $grid->dataType = 'json'; $grid->table = "orders"; $grid->setPrimaryKeyId("OrderID"); // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set grid caption using the option caption $grid->setGridOptions(array("caption" => "Datepicker method", "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"))); // Set the datepicker on OrderDate field. Note that the script automatically // converts the user date set in the jqGrid $grid->setDatepicker('OrderDate', array("buttonIcon" => true), true, false); $grid->datearray = array('OrderDate'); // Enjoy $grid->navigator = true; $grid->setNavOptions('navigator', array("search" => false, "excel" => false)); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;