In the following code $types contains “1:real;2:practice;12:incomplete.
The inline edit works from the select dropdown and changes the grid to show the relevant change however after stepping off the row or pressing Enter, the tr_cystestquestion is not being updated.
I am working on the assumption that in $grid->setAfterCrudAction(‘edit’, “update tr_cyotestquestion set TestTypeID = TestType WHERE CYOTestQuestionID=?”,array($cid)); TestType will contain the ID 1,2 or 12
Pleas let me know what I need to change or add.
// the actual query for the grid data
$grid->SelectCommand = “SELECT
tr_cyoquestion.CYOQuestionID,
tr_cyotestquestion.CYOTestQuestionID,
tr_cyoquestion.Title,
tr_cyoquestion.CuratorReference,
tr_cyocategory.Title AS Category,
tr_cyotestquestion.TestTypeID,
tr_cyotestquestion.SubTestID,
tr_cyotestquestion.SubTest2ID,
testtype.Name as TestType,
(SELECT
subtest.Name AS Name1
FROM
subtesttype
INNER JOIN subtest ON subtesttype.SubTestTypeID =
subtest.SubTestTypeID
INNER JOIN test ON test.SubTestTypeID = subtesttype.SubTestTypeID
where test.TestID = tr_cyotestquestion.TestID
and subtest.TestSubTestID = tr_cyotestquestion.SubTestID) as SubTest1,
(SELECT
subtest.Name AS Name1
FROM
subtesttype
INNER JOIN subtest ON subtesttype.SubTestTypeID =
subtest.SubTestTypeID
INNER JOIN test ON test.SubTestTypeID = subtesttype.SubTestTypeID
where test.TestID = tr_cyotestquestion.TestID
and subtest.TestSubTestID = tr_cyotestquestion.SubTest2ID) as SubTest2
FROM
tr_cyotestquestion
INNER JOIN tr_cyoquestion ON tr_cyotestquestion.CYOQuestionID = tr_cyoquestion.CYOQuestionID
LEFT JOIN tr_cyoquestioncategory ON tr_cyoquestion.CYOQuestionID = tr_cyoquestioncategory.CYOQuestionID
LEFT JOIN tr_cyocategory ON tr_cyoquestioncategory.CYOCategoryID = tr_cyocategory.CYOCategoryID
INNER JOIN testtype ON tr_cyotestquestion.TestTypeID = testtype.TestTypeID
WHERE
tr_cyotestquestion.FixedOrder IS 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(‘getTestQuestions.php?id=’.$TestID.’&types=’.$sTypes.’&subtest1=’.$sSubtest1.’&subtest2=’.$sSubtest2);
// Set some grid options
$grid->setGridOptions(array(
“caption”=>”Random Order questions for Test “.$id,
“rowNum”=>500,
“sortname”=>”Title”,
“altRows”=>true,
“rowList”=>array(500,1000),
“cellEdit”=>true,
“height”=>200,
“width”=>950
));
$grid->addCol(array(“name”=>”tact”),”last”);
// Change some property of the field(s)
$grid->setColProperty(“CYOQuestionID”, array(“label”=>”QID”, “width”=>30));
$grid->setColProperty(“CYOTestQuestionID”, array(“label”=>”ID”, “width”=>30));
$grid->setColProperty(“Title”, array(“label”=>”Title”, “width”=>150, “editable”=>false));
$grid->setColProperty(“CuratorReference”, array(“label”=>”Curator”, “width”=>120, “editable”=>true));
$grid->setColProperty(“Category”, array(“label”=>”Category”, “width”=>50, “editable”=>true));
$grid->setColProperty(“TestType”, array(“label”=>”Type”, “width”=>70, “editable”=>true, “edittype”=>”select”, “editoptions”=>array(“value”=>”{$types}”), “search”=>false));
$grid->setColProperty(“SubTest1”, array(“label”=>”Subtest 1”, “width”=>60, “editable”=>true, “edittype”=>”select”, “editoptions”=>array(“value”=>”{$subtest1}”), “search”=>false));
$grid->setColProperty(“SubTest2”, array(“label”=>”Subtest 2”, “width”=>60, “editable”=>true, “edittype”=>”select”, “editoptions”=>array(“value”=>”{$subtest2}”), “search”=>false));
$grid->setColProperty(“TestTypeID”, array(“label”=>”Test Type”, “hidden”=>true, “width”=>30, “stype”=>”select”, “searchoptions”=>array(“searchhidden”=>true, “sopt”=>array(“eq”),”value”=>”{$types}”)));
$grid->setColProperty(“SubTestID”, array(“label”=>”SubTest 1”, “hidden”=>true, “width”=>30, “stype”=>”select”, “searchoptions”=>array(“searchhidden”=>true, “sopt”=>array(“eq”),”value”=>”{$subtest1}”)));
$grid->setColProperty(“SubTest2ID”, array(“label”=>”SubTest 2”, “hidden”=>true, “width”=>30, “stype”=>”select”, “searchoptions”=>array(“searchhidden”=>true, “sopt”=>array(“eq”),”value”=>”{$subtest2}”)));
$grid->setColProperty(“tact”, array(“label”=>”Actions”, “width”=>50, “editable”=>false, “search”=>false));
$loadevent = <<<LOADCOMPLETE
function(rowid){
var ids = jQuery(“#qtlist”).getDataIDs();
for(var i=0;i<ids.length;i++){
var rowd = $(“#qtlist”).getRowData(ids);
var cl = ids;
st = ‘</ids>’;
jQuery(“#qtlist”).setRowData(ids,{tact:st});
}
}
LOADCOMPLETE;
$grid->setGridEvent(“loadComplete”,$loadevent);
// This command is executed after edit
$cid = jqGridUtils::GetParam(‘CYOTestQuestionID’);
send_to_log($cid,true);
// This command is executed immediatley after edit occur.
$grid->setAfterCrudAction(‘edit’, “update tr_cyotestquestion set TestTypeID = TestType WHERE CYOTestQuestionID=?”,array($cid));
$dragdrop = <<< DRAG
jQuery(‘#qavlist’).jqGrid(‘gridDnD’,{connectWith:’#qavlist,#qtlist,#qfolist’});
DRAG;
$grid->setJSCode($dragdrop);
// 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(‘#qtlist’,’#qtpager’,true, null, null,true,true,true);
$conn = null;
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top