// include the driver class 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 OrderID, Freight, OrderDate, ShipCity 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"), "search" => false)); // Enable navigator $grid->navigator = true; // Enable excel export $grid->setNavOptions('navigator', array("excel" => false, "add" => false, "edit" => false, "del" => false, "view" => false)); // add a custom button via the build in callGridMethod // note the js: before the function $buttonoptions = array("#pager", array("caption" => "Custom Button", "onClickButton" => "js: function(){alert('Custom Button clicked')}")); $grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions); // Enjoy $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;
// Set the url from where we obtain the data $grid->setUrl('../grids/email_group.php'); // Change some property of the field(s) $grid->setColProperty("id", array("editable" => false, "hidden" => true, "width" => 25, "fixed" => true, "label" => "ID")); $grid->setColProperty("name", array("editable" => true, "width" => 100, "fixed" => true, "label" => "Name")); $grid->setColProperty("dbsql", array("editable" => true, "edittype" => "textarea", "label" => "SQL", "width" => 750, "fixed" => true, "editoptions" => array("rows" => 10, "cols" => 80))); // Set alternate background using altRows property $grid->setGridOptions(array("sortable" => true, "width" => 1024, "height" => 250, "caption" => "Email Group Management", "rownumbers" => true, "rowNum" => 30, "sortname" => "name", "sortorder" => "asc", "toppager" => true, "rowList" => array(10, 20, 30, 50, 100))); $grid->showError = true; $grid->navigator = true; $grid->setNavOptions('navigator', array("pdf" => true, "excel" => true, "add" => true, "edit" => true, "del" => false, "view" => true, "search" => true)); $grid->setNavOptions('view', array("width" => 750, "dataheight" => 500, "viewCaption" => "Email Group Management")); $grid->setNavOptions('add', array("width" => 750, "dataheight" => 500, "closeOnEscape" => true, "closeAfterAdd" => true, "addCaption" => "Add Course", "bSubmit" => "Add Email Group", "reloadAfterSubmit" => false)); $grid->setNavOptions('edit', array("width" => 750, "dataheight" => 500, "closeOnEscape" => true, "closeAfterEdit" => true, "editCaption" => "Update Course", "bSubmit" => "Update Email Group", "reloadAfterSubmit" => false)); //$grid->toolbarfilter = true; $grid->callGridMethod('#grid', 'setFrozenColumns'); $grid->callGridMethod('#grid', 'gridResize'); global $htmlcode; $bindkeys = <<<KEYS \$("#grid").jqGrid('bindKeys', {"onEnter":function( rowid ) { var rowData = jQuery('#grid').jqGrid ('getRowData', rowid); } } ); KEYS; $grid->setJSCode($bindkeys); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $DB = null; ?>
// Change some property of the field(s) $grid->setColProperty("id", array("editable" => false, "hidden" => true, "label" => "ID")); $grid->setColProperty("candidateid", array("editable" => false, "frozen" => true, "width" => 200, "fixed" => true, "label" => "Candidate Name", "edittype" => "select")); $grid->setSelect("candidateid", "SELECT distinct candidateid as id, name as name FROM candidate order by name"); $grid->setColProperty("mmid", array("editable" => true, "frozen" => true, "width" => 100, "fixed" => true, "label" => "Manager", "edittype" => "select")); $grid->setSelect("mmid", "SELECT distinct id, name FROM employee order by name"); $grid->setColProperty("interviewdate", array("formatter" => "date", "width" => 80, "fixed" => true, "formatoptions" => array("srcformat" => "Y-m-d", "newformat" => "Y-m-d"), "editable" => true, "label" => "Date", "editoptions" => array("dataInit" => "js:function(elm){setTimeout(function(){\n \t\t\t\t\t\t\t jQuery(elm).datepicker({dateFormat:'yy-mm-dd'});\n \t\t\t\t\t\t\t jQuery('.ui-datepicker').css({'font-size':'75%'});\n \t\t\t\t\t\t\t\t\t },200);}"), "searchoptions" => array("dataInit" => "js:function(elm){setTimeout(function(){\n \t\t\t\t\t\t\t jQuery(elm).datepicker({dateFormat:'yy-mm-dd'});\n \t\t\t\t\t\t\t jQuery('.ui-datepicker').css({'font-size':'75%'});\n \t\t\t\t\t\t\t\t\t },200);}"))); $grid->setColProperty("type", array("editable" => false, "width" => 70, "fixed" => true, "label" => "Type", "edittype" => "select")); $grid->setSelect("type", $interviewtype, false, true, true, array("" => "All")); $grid->setColProperty("clientname", array("editable" => true, "width" => 90, "fixed" => true, "label" => "Client Name")); $grid->setColProperty("clientlocation", array("editable" => true, "width" => 90, "fixed" => true, "label" => "Client Location")); $grid->setColProperty("result", array("editable" => true, "width" => 70, "fixed" => true, "label" => "Result", "edittype" => "select")); $grid->setSelect("result", $interviewresult, false, true, true, array("" => "All")); $grid->setColProperty("performance", array("editable" => true, "width" => 70, "fixed" => true, "label" => "Performance", "edittype" => "select")); $grid->setSelect("performance", $interviewperf, false, true, true, array("" => "All")); $grid->setColProperty("reclink", array("editable" => true, "frozen" => true, "width" => 400, "formatter" => "link", "formatoptions" => array("target" => "_blank"), "fixed" => true, "editrules" => array("url" => true, "required" => false), "label" => "Recording Link")); $grid->setColProperty("questionslink", array("editable" => true, "frozen" => true, "width" => 400, "formatter" => "link", "formatoptions" => array("target" => "_blank"), "fixed" => true, "editrules" => array("url" => true, "required" => false), "label" => "Ques Link")); $grid->setColProperty("questions", array("editable" => true, "hidden" => true, "edittype" => "textarea", "editrules" => array("edithidden" => true, "required" => false), "editoptions" => array("rows" => 6, "cols" => 80), "label" => "Questions")); $grid->setColProperty("notes", array("editable" => true, "width" => 70, "fixed" => true, "edittype" => "textarea", "editrules" => array("edithidden" => true, "required" => false), "editoptions" => array("rows" => 6, "cols" => 80), "label" => "Notes")); $grid->setGridOptions(array("sortable" => true, "width" => 1024, "height" => 250, "caption" => "All Interviews", "rownumbers" => true, "rowNum" => 100, "shrinkToFit" => false, "sortname" => "interviewdate", "sortorder" => "desc", "toppager" => true, "rowList" => array(10, 20, 30, 50, 100, 500))); $grid->showError = true; $grid->navigator = true; $grid->setNavOptions('navigator', array("pdf" => false, "excel" => false, "add" => false, "edit" => false, "del" => false, "view" => true, "search" => true)); $grid->setNavOptions('view', array("width" => 750, "dataheight" => 500, "viewCaption" => "All Interviews")); $grid->callGridMethod('#grid', 'setFrozenColumns'); $bindkeys = <<<KEYS \$("#grid").jqGrid('bindKeys', {"onEnter":function( rowid ) { alert("You enter a row with id:"+rowid)} } ); KEYS; $grid->setJSCode($bindkeys); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $DB = null;
<?php require_once '../../../jq-config.php'; // include the jqGrid Class require_once ABSPATH . "php/jqGrid.php"; // Create the jqGrid instance $grid = new jqGridRender(); // Lets create the model manually $Model = array(array("name" => "Integer", "width" => 80, "formatter" => "integer", "formatoptions" => array("thousandsSeparator" => ","), "sorttype" => "integer"), array("name" => "Number", "width" => 80, "formatter" => "number", "formatoptions" => array("decimalPlaces" => 1), "sorttype" => "number"), array("name" => "Currency", "width" => 80, "formatter" => "currency", "formatoptions" => array("decimalPlaces" => 1, "thousandsSeparator" => ",", "prefix" => "\$", "suffix" => " USD"), "sorttype" => "currency"), array("name" => "Email", "width" => 120, "formatter" => "email"), array("name" => "Link", "width" => 120, "formatter" => "link"), array("name" => "Checkbox", "width" => 50, "formatter" => "checkbox")); // Let the grid create the model $grid->setColModel($Model); // Set grid option datatype to be local $grid->setGridOptions(array("datatype" => "local")); //We can add data manually using arrays $data = array(array("Integer" => 200000, "Number" => 60000000.73, "Currency" => 34.2, "Email" => "*****@*****.**", "Link" => "http://www.yahoo.com", "Checkbox" => "Yes"), array("Integer" => 1600000, "Number" => 75200000.23, "Currency" => 245.2, "Email" => "*****@*****.**", "Link" => "http://www.google.com", "Checkbox" => "Yes"), array("Integer" => 652693, "Number" => 34534000.33, "Currency" => 18545.2, "Email" => "*****@*****.**", "Link" => "http://www.bing.com", "Checkbox" => "No"), array("Integer" => 1237, "Number" => 3450.3, "Currency" => 55597545.2, "Email" => "*****@*****.**", "Link" => "http://www.msn.com", "Checkbox" => "No")); // Let put it using the callGridMethod $grid->callGridMethod("#grid", 'addRowData', array("Integer", $data)); $grid->renderGrid('#grid', '#pager', true, null, null, true, true);
// 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;
require_once '../../../jq-config.php'; // include the jqGrid Class require_once ABSPATH . "php/jqGrid.php"; // include the driver class 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 OrderID, RequiredDate, ShipName, ShipCity, Freight FROM orders'; // set the ouput 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, 130), "sortname" => "OrderID")); // Enable footerdata an tell the grid to obtain it from the request $grid->setGridOptions(array("footerrow" => true, "userDataOnFooter" => true)); // Change some property of the field(s) $grid->setColProperty("RequiredDate", array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y"))); // At end call footerData to put total label $grid->callGridMethod('#grid', 'footerData', array("set", array("ShipCity" => "Total:"))); // Set which parameter to be sumarized $summaryrows = array("Freight" => array("Freight" => "SUM")); $grid->renderGrid('#grid', '#pager', true, $summaryrows, 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/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 OrderID, OrderDate, CustomerID, Freight, ShipName, ShipCity, ShipCountry FROM orders'; // set the ouput format to json $grid->dataType = 'json'; // Let the grid create the model from SQL query $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set alternate background using altRows property $grid->setGridOptions(array("rowNum" => 10, "sortname" => "OrderID", "rowList" => array(10, 20, 50), "height" => 'auto')); // 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 // Set grouping header using callGridMethod $grid->callGridMethod("#grid", "setGroupHeaders", array(array("useColSpanStyle" => true, "groupHeaders" => array(array("startColumnName" => 'OrderID', "numberOfColumns" => 2, "titleText" => 'Order Info'), array("startColumnName" => 'ShipName', "numberOfColumns" => 3, "titleText" => 'Shipping Details'))))); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;