\$("#mne_dialog").ready(function(){ // Some magic to set the proper width of the grid inside a Modal window var modalWidth = \$("#mne_dialog").width(); var modalHeight = \$("#mne_dialog").height() - 52; \$('#mnegrid').jqGrid('setGridWidth',modalWidth); \$('#mnegrid').jqGrid('setGridHeight',modalHeight); \$('#mnegrid').fluidGrid({base:'#mne_dialog', offset:-25}); }); //--------------------------------------------------------------- // END: Mnemonic Select Dialog //--------------------------------------------------------------- }); \$(window).resize(function() { \$('#mnegrid').fluidGrid({base:'#ui-dialog-title-mne_dialog', offset:-25}); }); CUSTOM; $grid->setJSCode($custom); $oper = jqGridUtils::GetParam("oper"); if ($oper == "pdf") { $grid->setPdfOptions(array("header" => true, "margin_top" => 25, "page_orientation" => "P", "header_logo" => "../../../../../images/Logo_450x123_24bit_color.jpg", "header_logo_width" => 45, "header_title" => " Mnemonics Report")); } // Enjoy $summaryrows = array("Seen" => array("Seen" => "SUM")); $grid->renderGrid('#mnegrid', '#mnepager', true, $summaryrows, 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; ?>
$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 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', "grouping" => true, "groupingView" => array("groupField" => array('CustomerID'), "groupColumnShow" => array(true), "groupText" => array('<b>{0}</b>'), "groupDataSorted" => true))); // 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"))); // Change grouping $dynamic = <<<DYNAMIC jQuery("#chngroup").change(function(){ \tvar vl = \$(this).val(); \tif(vl) { \t\tif(vl == "clear") { \t\t\tjQuery("#grid").jqGrid('groupingRemove',true); \t\t} else { \t\t\tjQuery("#grid").jqGrid('groupingGroupBy',vl); \t\t} \t} }); DYNAMIC; $grid->setJSCode($dynamic); // Enjoy $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;
$grid->setUrl('detail.php'); // Set some grid options $grid->setGridOptions(array("rowNum" => 10, "footerrow" => true, "userDataOnFooter" => true, "sortname" => "OrderID", "height" => 110)); // 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"), "search" => false)); // on beforeshow form when add we get the customer id and set it for posting $beforeshow = <<<BEFORE function(formid) { var srow = jQuery("#grid").jqGrid('getGridParam','selrow'); if(srow) { \tvar gridrow = jQuery("#grid").jqGrid('getRowData',srow); \t\$("#CustomerID",formid).val(gridrow.CustomerID); } } BEFORE; // disable the CRUD buttons when we initialy load the grid $initgrid = <<<INIT jQuery("#add_detail").addClass("ui-state-disabled"); jQuery("#edit_detail").addClass("ui-state-disabled"); jQuery("#del_detail").addClass("ui-state-disabled"); INIT; $grid->setJSCode($initgrid); $grid->setColProperty("EmployeeID", array("hidden" => false, "width" => 20)); $grid->navigator = true; $grid->setNavOptions('navigator', array("excel" => true, "add" => true, "edit" => true, "del" => true, "view" => false)); $grid->setNavEvent('add', 'beforeShowForm', $beforeshow); // Enjoy $summaryrow = array("Freight" => array("Freight" => "SUM")); $grid->renderGrid("#detail", "#pgdetail", true, $summaryrow, array((int) $rowid), 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, 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 setJSCode method $grouping = <<<GROUP jQuery("#grid").jqGrid('setGroupHeaders',{ \t"useColSpanStyle":false, \t"groupHeaders" : [ \t\t{ "startColumnName":'OrderID', "numberOfColumns":2, "titleText":'Order Info' }, \t\t{ "startColumnName":'ShipName', "numberOfColumns":3, "titleText":'Shipping Details' } \t] }); GROUP; $grid->setJSCode($grouping); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); $conn = null;