My subgrid returns the correct records in json (as seen in firebug). The main grid then has the headings for the subgrid and the correct number of rows but there is no data displayed in the rows.
Main Grid
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 |
include '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); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // Get the needed parameters passed from the main grid if(isset ($_REQUEST["cid"])) { $id = jqGridUtils::Strip($_REQUEST["cid"]); $i = explode('~',$id); $draccno = $i[0]; $drsubno = $i[1]; } else { $draccno = 0; $drsubno = 0; } // Create the jqGrid instance $grid = new jqGridRender($conn); // the actual query for the grid data $grid->SelectCommand = "select ref_no,uid,ddate,totvalue,tax from ".$moduledb.".invhead where accountno = ".$draccno." and sub = ".$drsubno; // set the ouput format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(null); // Set the url from where we obtain the data $grid->setUrl('getdrtrans.php'); // Set some grid options $grid->setGridOptions(array( "rowNum"=>7, "sortname"=>"ddate", "sortorder"=>"desc", "rowList"=>array(7,50,100), "height"=>150, "width"=>750 )); $grid->addCol(array("name"=>"act"),"last"); // Change some property of the field(s) $grid->setColProperty("ref_no", array("label"=>"Reference", "width"=>50)); $grid->setColProperty("uid", array("label"=>"ID", "width"=>25, "hidden"=>true)); $grid->setColProperty("ddate", array("label"=>"Date", "width"=>100, "formatter"=>"date", "formatoptions"=>array("srcformat"=> "Y-m-d", "newformat"=>"d/m/Y"))); $grid->setColProperty("totvalue", array("label"=>"Value", "width"=>100, "align"=>"right","formatter"=>"number")); $grid->setColProperty("tax", array("label"=>"Tax", "width"=>100, "align"=>"right","formatter"=>"number")); $grid->setColProperty("act", array("label"=>"Actions", "width"=>50)); $grid->setSubGrid("getAllocations.php", array('Date', 'Amount', 'From', 'To'), array(80,80,70,70), array('left','right','left','left')); $loadevent = <<<LOADCOMPLETE function(rowid){ var ids = jQuery("#drtranslist").getDataIDs(); for(var i=0;i<ids.length;i++){ var rowd = $("#drtranslist").getRowData(ids<em class="d4pbbc-italic"></em>); var cl = ids<em class="d4pbbc-italic"></em>; var rf = "'"+rowd.ref_no+"'"; be = '<img src="../images/into.png" title="View Transaction Details" onclick="javascript:viewtrans('+rf+')" ></ids>'; se = '<img src="../images/printer.gif" title="Print Document" onclick="javascript:printdoc('+rf+')" ></ids>'; jQuery("#drtranslist").setRowData(ids<em class="d4pbbc-italic"></em>,{act:be+' '+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)); // Run the script $grid->renderGrid('#drtranslist','#drtranspager',true, null, null,true,true,true); |
Sub Grid code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
include '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); // Get the needed parameters passed from the main grid $rowid = jqGridUtils::Strip($_REQUEST["id"]); if(!$rowid) die("Missed parameters"); // Create the jqGrid instance $grid = new jqGrid($conn); // Write the SQL Query $grid->SubgridCommand = "select ddate,amount,fromref,toref from allocations where (fromref = '".$rowid."' or toref = '".$rowid."')"; // set the ouput format to json $grid->dataType = 'json'; // Use the build in function for the simple subgrid $grid->querySubGrid(array(&$rowid)); $conn = null; |
This same methodology works elsewhere. Please let me know what I am doing wrong here.
Regards
Murray
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top