This is old code that used to work. jqGrid ver 3.8. jqGrid.log returns
[time] => 2018-07-21 16:29:10
[query] => SELECT policies.policy_id,policies.policy_no,policies.provider,policies.renewal_date,policies.pay_period,providers.logon_url from policies,polowners,providers where policies.policy_id = polowners.policy_id and polowners.member_id = 20828 and policies.provider = providers.provider ORDER BY policy_no asc LIMIT 0, 12
[data] =>
[types] =>
[fields] =>
[primary] =>
[input] =>
which select statement correctly returns the records. The grid is being created but has no rows in it. Are you able to tell me why please. Code for grid as follows:-
|
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 |
<?php session_start(); $id = $_SESSION['s_memberid']; // where clause $where = " where policies.policy_id = polowners.policy_id and polowners.member_id = ".$id." and policies.provider = providers.provider"; require_once '../includes/jquery/jq-config.php'; // include the jqGrid Class require_once "../includes/jquery/php/jqGrid.php"; // include the PDO driver class require_once "../includes/jquery/php/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Create the jqGrid instance $grid = new jqGridRender($conn); // enable debugging $grid->debug = true; // the actual query for the grid data $grid->SelectCommand = "SELECT policies.policy_id,policies.policy_no,policies.provider,policies.renewal_date,policies.pay_period,providers.logon_url from policies,polowners,providers ".$where; // 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('getpoliciesom.php'); // Set grid caption using the option caption $grid->setGridOptions(array( "rowNum"=>12, "sortname"=>"policy_no", "rowList"=>array(12,30,50), "height"=>115, "width"=>500 )); $grid->addCol(array("name"=>"act"),"first"); // Change some property of the field(s) $grid->setColProperty("policy_id", array("label"=>"ID", "width"=>20, "hidden"=>true)); $grid->setColProperty("policy_no", array("label"=>"Policy No.", "width"=>70)); $grid->setColProperty("provider", array("label"=>"Provider", "width"=>90)); $grid->setColProperty("logon_url", array("label"=>"Login", "width"=>90, "hidden"=>true)); //$grid->setColProperty("commenced", array("label"=>"Commenced", "width"=>70, "formatter"=>"date")); $grid->setColProperty("renewal_date", array("label"=>"Renewal", "width"=>70, "formatter"=>"date")); $grid->setColProperty("pay_period", array("label"=>"Pay Period", "width"=>70)); $grid->setColProperty("act", array("label"=>"Actions", "width"=>70)); // on select row we should post the policy id to second table and trigger it to reload the data $selectcover = <<<COVER function(rowid, selected) { if(rowid != null) { jQuery("#mcoverlisto").jqGrid('setGridParam',{postData:{polid:rowid}}); jQuery("#mcoverlisto").trigger("reloadGrid"); } } COVER; $grid->setGridEvent('onSelectRow', $selectcover); // We should clear the grid data on second grid on sorting, paging, etc. $cleargrid = <<<CLEAR function(rowid, selected) { // clear the grid data and footer data jQuery("#mcoverlisto").jqGrid('clearGridData',true); } CLEAR; $grid->setGridEvent('onPaging', $cleargrid); $grid->setGridEvent('onSortCol', $cleargrid); $loadevent = <<<LOADCOMPLETE function(rowid){ var ids = jQuery("#mpolicylisto").getDataIDs(); for(var i=0;i<ids.length;i++){ var rowd = $("#mpolicylisto").getRowData(ids<em class="d4pbbc-italic"></em>); var prov = rowd.logon_url; var provd = "'"+prov+"'"; var from = "'m'"; var mmember = $id; var cl = ids<em class="d4pbbc-italic"></em>; be = '<img src="../images/edit.png" title="Edit" onclick="javascript:editpolicy('+cl+','+from+','+mmember+')" >'; le = '<img src="../images/logonurl.gif" title="Logon to Provider" onclick="javascript:logonurl('+provd+')" >'; se = '<img src="../images/delete.png" title="Delete" onclick="javascript:delpolicy('+cl+','+from+','+mmember+')" >'; jQuery("#mpolicylisto").setRowData(ids<em class="d4pbbc-italic"></em>,{act:be+'&nbsp;&nbsp;&nbsp;&nbsp;'+le+'&nbsp;&nbsp;&nbsp;&nbsp;'+se}) ; } } LOADCOMPLETE; $grid->setGridEvent("loadComplete",$loadevent); // Enable navigator $grid->navigator = true; // Disable some actions $grid->setNavOptions('navigator', array("excel"=>true,"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("#mpolicypagero", array("buttonicon"=>"ui-icon-plus","caption"=>"","position"=>"first","title"=>"Add a policy", "onClickButton"=>"js: function(){addpolicy('m','O');}") ); $grid->callGridMethod("#mpolicylisto", "navButtonAdd", $buttonoptions); // Run the script $grid->renderGrid('#mpolicylisto','#mpolicypagero',true, null, null, true,true); ?> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top