Many thanks for your prompt reply, however neither suggestion works. jqGrid refuses to recognise the variable TestID on the second pass.
either using: // Set the url from where we obtain the data
$grid->setUrl(‘getTestQuestionsFO.php?id=’.$TestID);
or
<?php
include_once ‘jq-config.php’;
// include the jqGrid Class
require_once “../javascript/jqgrid/php/jqGrid.php”;
// include the PDO driver class
require_once “../javascript/jqgrid/php/jqGridPdo.php”;
if(!isset($TestID) ) {
$TestID = jqGridUtils::GetParam($TestID);
}
$id = $TestID;
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// options
//$grid->setGridOptions(array(“id”=>$TestID));
// the actual query for the grid data
$grid->SelectCommand = “SELECT
tr_cyotestquestion.TestID,
tr_cyotestquestion.FixedOrder,
tr_cyoquestion.Title,
tr_cyoquestion.CYOQuestionID
FROM
tr_cyoquestion
INNER JOIN tr_cyotestquestion ON tr_cyotestquestion.CYOQuestionID = tr_cyoquestion.CYOQuestionID
WHERE
tr_cyotestquestion.FixedOrder IS NOT NULL and
tr_cyotestquestion.TestID = “.$id;
// 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(‘getTestQuestionsFO.php’);
// Set some grid options
$grid->setGridOptions(array(
“caption”=>”Fixed Order questions for Test “,
“rowNum”=>20,
“sortname”=>”FixedOrder”,
“altRows”=>true,
“rowList”=>array(20,100,200),
“height”=>250,
“width”=>400
));
$grid->addCol(array(“name”=>”act”),”last”);
// Change some property of the field(s)
$grid->setColProperty(“TestID”, array(“label”=>”ID”, “width”=>25));
$grid->setColProperty(“FixedOrder”, array(“label”=>”FixedOrder”, “width”=>25, “hidden”=>true));
$grid->setColProperty(“Title”, array(“label”=>”Title”, “width”=>200));
$grid->setColProperty(“CYOQuestionID”, array(“label”=>”CYOQuestionID”, “width”=>20, “hidden”=>true));
$grid->setColProperty(“act”, array(“label”=>”Actions”, “width”=>50));
$loadevent = <<<LOADCOMPLETE
function(rowid){
var ids = jQuery(“#qfolist”).getDataIDs();
for(var i=0;i<ids.length;i++){
var rowd = $(“#qfolist”).getRowData(ids);
var cl = ids;
sh = ‘
</ids>’;
jQuery(“#qfolist”).setRowData(ids,{act:sh});
}
}
LOADCOMPLETE;
$grid->setGridEvent(“loadComplete”,$loadevent);
// Enable navigator
$grid->navigator = true;
// Disable some actions
$grid->setNavOptions(‘navigator’, array(“excel”=>false,”add”=>false,”edit”=>false,”del”=>false,”view”=>false));
// Run the script
$grid->renderGrid(‘#qfolist’,’#qfopager’,true, null,null,true,true,true);
$conn = null;
?>
I have also tried Tony’s suggested
$grid->renderGrid(‘#qfolist’,’#qfopager’,true, array($id),null,true,true,true);
with $grid->setColModel(null,array($id));
Any idea what I am doing wrong?