My first attempt at a pivot grid which I need as a grid called from another grid. The first grid has
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// on select row we should post the member id to second table and trigger it to reload the data $selecttype = <<<CAND function(rowid, selected) { if(rowid != null) { jQuery("#ProjectCandidateList").jqGrid('setGridParam',{postData:{nproj:rowid}}); jQuery("#ProjectCandidateList").trigger("reloadGrid"); } } CAND; $grid->setGridEvent('onSelectRow', $selecttype); // 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("#ProjectCandidateList").jqGrid('clearGridData',true); } CLEAR; $grid->setGridEvent('onPaging', $cleargrid); $grid->setGridEvent('onSortCol', $cleargrid); |
and the called ProjectCandidateList code is as follows. Something is going wrong while forming the grid, It is doing a first pass in which id is 0 but never does the second pass with the id passed from the first grid. Is there something wrong with the creation of the second grid which is the pivot grid? I use my own pdo object $g_pdoHandle to get the data in many grids without a problem.
|
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 |
<?php // Our grids ID $sGridID="ProjectCandidateList"; $sGridObjectID="#{$sGridID}"; if(isset($_REQUEST['nproj'])) { $id = jqGridUtils::Strip($_REQUEST["nproj"]); } else { $id = 0; } // Create the jqGrid instance $pivot = new jqPivotGrid($g_pdoHandle); // the actual query for the grid data $sSQL = "SELECT projectcandidate.ProjectCandidateID, concat(candidate.Forename,' ',candidate.Surname) as CandidateName, test.Name as TestName, testtaken.HeadlineScoreCalcPC, testtaken.ScoreCalcSpeed, projectcandidate.OrganisationProjectID FROM projectcandidate LEFT JOIN candidate ON projectcandidate.CandidateID = candidate.CandidateID LEFT JOIN testassignment ON projectcandidate.CandidateID = testassignment.CandidateID LEFT JOIN test ON testassignment.TestID = test.TestID LEFT JOIN testtaken ON testassignment.TestAssignmentID = testtaken.TestAssignmentID WHERE projectcandidate.OrganisationProjectID = {$id}"; send_to_log($sSQL); $pivot->SelectCommand = $sSQL; // Set the url from where we obtain the data $pivot->setUrl(current_path("jqgridGetProjectCandidates")); // Set some grid options $pivot->setGridOptions(array( "rowNum"=>25, "rowList"=>array(25,100,200,$sShowAll), "height"=>"100%", "altRows"=>true, "autowidth"=> true, "responsive"=> true, "forceFit"=>true, "caption"=>"Project Candidates", "hidegrid"=>false, "loadtext"=>"<p>".translator_get_text("Loading, please wait...","SharedUI")."</p><p><img src='".get_resource_path("images/processing-32x32.gif")."'></p>", "recordtext" => translator_get_text("Viewing {0} - {1} of {2}","SharedUI"), "emptyrecords"=> translator_get_text("No records to view","SharedUI"), "savetext"=> translator_get_text("Saving...","SharedUI"), "pgtext" => translator_get_text("Page {0} of {1}","SharedUI"), "pgfirst" => translator_get_text("First Page","SharedUI"), "pglast" => translator_get_text("Last Page","SharedUI"), "pgnext" => translator_get_text("Next Page","SharedUI"), "pgprev" => translator_get_text("Previous Page","SharedUI"), "pgrecs" => translator_get_text("Records per Page","SharedUI"), "showhide"=> translator_get_text("Toggle Expand Collapse Grid","SharedUI") ) ); // Grid xDimension settings $pivot->setxDimension(array( array("dataName"=>"CandidateName", "width"=>100) )); // Grid yDimension settings $pivot->setyDimension(array( array("dataName" => "TestName") )); // Members $pivot->setaggregates(array( array( "member"=>'HeadlineScoreCalcPC', "aggregator"=>'avg', "width"=>80, "label"=>'Score', "formatter"=>'number', "align"=>'right' ), array( "member"=>'ScoreCalcSpeed', "aggregator"=>'avg', "width"=>80, "label"=>'Speed', "formatter"=>'number', "align"=>'right' ) )); // Set the pivot options $pivot->setPivotOptions(array( "rowTotals" => true, "colTotals" => true )); $pivot->renderPivot($sGridObjectID,"{$sGridObjectID}Pager",true, null,true,true); ?> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top