I’ve reviewed the main documents on passing parameters to filter the jqgrid SQL query.
Using the GET method, the parameter is successfully passed to the 2nd invocation of the grid script, and something happens because there is no result set. I’ve captured the SQL query and run it successfully in phpMyAdmin, so it’s clear there’s something in the setup at fault. When I hardcode a value in the SQL query, there also is no result set.
I’ve also used the $_SESSION method recommended to avoid SQL injection (which is not a concern for this instance). Here, the $_SESSION variable is not available in the 2nd invocation.
I’m sure this is something simple. But, I’m at a loss. TIA for your help.
SOURCE BELOW:
GET METHOD.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
<?php require_once'jq-config.php'; // include the jqGrid Class require_once ABSPATH."php/PHPSuito/jqAutocomplete.php"; require_once ABSPATH."php/PHPSuito/jqCalendar.php"; require_once ABSPATH."php/PHPSuito/jqGrid.php"; // include the driver class require_once ABSPATH."php/PHPSuito/DBdrivers/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); $jvs_user_id = $_REQUEST['jvs_user_id'] ; $param1 = (isset($jvs_user_id)) ? $jvs_user_id : $USER->id ; // set the ouput format to json $grid->dataType = 'json'; $grid->table ="mdl_centerstatus"; $grid->setPrimaryKeyId("id"); $grid->setUrl('grid_center.php?jvs_user_id='.$param1); $grid->cacheCount = true; $grid->SelectCommand = 'SELECT id, ' . 'user_id, ' . 'cohort_id, ' . 'cohort_name, ' . 'date_course_complete, ' . 'gospel_pres_prv_yr, ' . 'gospel_pres_m_1, ' . 'gospel_pres_m_2, ' . 'gospel_pres_m_3, ' . 'gospel_pres_m_4, ' . 'gospel_pres_m_5, ' . 'gospel_pres_m_6, ' . 'gospel_pres_tot_m_6, ' . 'preg_test_prv_yr, ' . 'preg_test_m_1, ' . 'preg_test_m_2, ' . 'preg_test_m_3, ' . 'preg_test_m_4, ' . 'preg_test_m_5, ' . 'preg_test_m_6, ' . 'preg_test_tot_m_6, ' . 'commit_prv_yr, ' . 'commit_m_1, ' . 'commit_m_2, ' . 'commit_m_3, ' . 'commit_m_4, ' . 'commit_m_5, ' . 'commit_m_6, ' . 'commit_tot_m_6, ' . 'complete_date_m_6, ' . 'grant_date ' . 'FROM mdl_centerstatus ' . "WHERE user_id = " . $param1 ; // . $param1 ; // Set grid caption using the option caption $grid->setGridOptions(array( "caption"=>"Center Status", "rowNum"=>10, "sortname"=>"cohort_name", "hoverrows"=>true, "height"=> 300, "width"=> 700, "shrinkToFit"=> false, "rowList"=>array(10,20,50), "postData"=>array("grid_recs"=>776) )); // Change some property of the field(s) $grid->setColProperty("id", array("label"=>"ID", "width"=>30, "editable"=>false, "hidden"=>true, "frozen"=>true)); $grid->setColProperty("user_id", array("label"=>"User", "width"=>30, "editable"=>false, "frozen"=>true)); $grid->setColProperty("cohort_id", array("label"=>"Cent ID", "width"=>40, "editable"=>false, "frozen"=>true)); $grid->setColProperty("cohort_name", array("label"=>"Name", "width"=>130, "editable"=>false, "frozen"=>true)); $grid->setColProperty("date_course_complete", array("label"=>"Completed", "width"=>70, "editable"=>false, "frozen"=>true)); $grid->setColProperty("gospel_pres_prv_yr", array("label"=>"Gosp Lst", "width"=>60, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_prv_yr", array("label"=>"Preg Lst", "width"=>60, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_prv_yr", array("label"=>"Comm Lst", "width"=>60, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_1", array("label"=>"Gosp 1", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_1", array("label"=>"Preg 1", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_1", array("label"=>"Comm 1", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_2", array("label"=>"Gosp 2", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_2", array("label"=>"Preg 2", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_2", array("label"=>"Comm 2", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_3", array("label"=>"Gosp 3", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_3", array("label"=>"Preg 3", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_3", array("label"=>"Comm 3", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_4", array("label"=>"Gosp 4", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_4", array("label"=>"Preg 4", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_4", array("label"=>"Comm 4", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_5", array("label"=>"Gosp 5", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_5", array("label"=>"Preg 5", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_5", array("label"=>"Comm 5", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_m_6", array("label"=>"Gosp 6", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("preg_test_m_6", array("label"=>"Preg 6", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("commit_m_6", array("label"=>"Comm 6", "width"=>50, "editable"=>true, "align"=>"right")); $grid->setColProperty("gospel_pres_tot_m_6", array("label"=>"Gosp 6 Tot", "width"=>70, "editable"=>false, "align"=>"right")); $grid->setColProperty("preg_test_tot_m_6", array("label"=>"Preg 6 Tot", "width"=>70, "editable"=>false, "align"=>"right")); $grid->setColProperty("commit_tot_m_6", array("label"=>"Comm 6 Tot", "width"=>70, "editable"=>false, "align"=>"right")); $grid->setColProperty("complete_date_m_6", array("label"=>"6 Mon Complete", "width"=>70, "editable"=>false,)); $grid->setColProperty("grant_date", array("label"=>"Grant Date", "width"=>70, "editable"=>false,)); $grid->setColProperty('date_course_complete', array("formatter"=>"date", "formatoptions"=>array("reformatAfterEdit"=>true, "srcformat"=>"Y-m-d", "newformat"=>"m-d-Y") ) ); $grid->setColProperty('complete_date_m_6', array("formatter"=>"date", "formatoptions"=>array("reformatAfterEdit"=>true, "srcformat"=>"Y-m-d", "newformat"=>"m-d-Y") ) ); $grid->setColProperty('grant_date', array("formatter"=>"date", "formatoptions"=>array("reformatAfterEdit"=>true, "srcformat"=>"Y-m-d", "newformat"=>"m-d-Y") ) ); $grid->setDatepicker("date_course_complete",array("buttonOnly"=>false)); $grid->setDatepicker("complete_date_m_6",array("buttonOnly"=>false)); $grid->setDatepicker("grant_date",array("buttonOnly"=>false)); // Enjoy $grid->navigator = true; $grid->setNavOptions('navigator', array("excel"=>true,"add"=>true,"edit"=>true,"del"=>true,"view"=>false, "search"=>true)); // Close the dialog after editing $grid->setNavOptions('edit',array("closeAfterEdit"=>true,"editCaption"=>"Update","bSubmit"=>"Update")); // Call the frozen cols method $grid->callGridMethod('#grid', 'setFrozenColumns'); $grid->exportfile = 'Report.xls'; // calculate the monthsum field $calcs = <<< CALCS function(postdata) { postdata['gospel_pres_tot_m_6'] = parseInt(postdata['gospel_pres_m_1']) + parseInt(postdata['gospel_pres_m_2']) + parseInt(postdata['gospel_pres_m_3']) + parseInt(postdata['gospel_pres_m_4']) + parseInt(postdata['gospel_pres_m_5']) + parseInt(postdata['gospel_pres_m_6']); postdata['preg_test_tot_m_6'] = parseInt(postdata['preg_test_m_1']) + parseInt(postdata['preg_test_m_2']) + parseInt(postdata['preg_test_m_3']) + parseInt(postdata['preg_test_m_4']) + parseInt(postdata['preg_test_m_5']) + parseInt(postdata['preg_test_m_6']); postdata['commit_tot_m_6'] = parseInt(postdata['commit_m_1']) + parseInt(postdata['commit_m_2']) + parseInt(postdata['commit_m_3']) + parseInt(postdata['commit_m_4']) + parseInt(postdata['commit_m_5']) + parseInt(postdata['commit_m_6']); return postdata; } CALCS; $grid->setNavEvent("edit", "serializeEditData", $calcs); $grid->renderGrid('#grid','#pager',true, null, null, true,true); ?> |
$_SESSION Method
|
1 |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top