I have a page with three grids. I can drag from the top on to the other two. I am trying to get the record dropped into the second grid ‘#qfolist’ to insert a record into the relevant table in the database. In order to do this I am trying to see what data is held in getdata in the function associated with ondrop (which according what I have read should hold the data from the dropped row. Once I have that I will pass it to some php url to do the actual insert. However the code with the ondrop does not seem to be fired. Is my syntax correct please.
|
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
<?php include_once '../includes/jq-config.php'; // include the jqGrid Class require_once "../javascript/Guriddo/php/PHPSuito/jqGrid.php"; // include the PDO driver class require_once "../javascript/Guriddo/php/PHPSuito/DBdrivers/jqGridPdo.php"; if(!isset($TestID) ) { $TestID = jqGridUtils::GetParam('id',''); } $id = $TestID; if(!isset($sTypes) ) { $sTypes = jqGridUtils::GetParam('types',''); } $types = $sTypes; if(!isset($sSubtest1) ) { $sSubtest1 = jqGridUtils::GetParam('subtest1',''); } $subtest1 = $sSubtest1; if(!isset($sSubtest2) ) { $sSubtest2 = jqGridUtils::GetParam('subtest2',''); } $subtest2 = $sSubtest2; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Create the jqGrid instance $grid = new jqGridRender($conn); // Set the url from where we obtain the data $grid->setUrl('getTestQuestionsFO.php?id='.$TestID.'&types='.$sTypes.'&subtest1='.$sSubtest1.'&subtest2='.$sSubtest2); // enable debugging $grid->debug = true; // 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 Name2 FROM subtesttype INNER JOIN subtest ON subtesttype.SubTestTypeID = subtest.SubTestTypeID INNER JOIN test ON test.SubTest2TypeID = 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 NOT NULL and tr_cyotestquestion.TestID = ".$id; // set the ouput format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(); // Set some grid options $grid->setGridOptions(array( "caption"=>"Fixed Order questions for Test ".$id, "rowNum"=>500, "sortname"=>"Title", "altRows"=>true, "rowList"=>array(500,1000), "cellEdit"=>true, "cellsubmit"=>"remote", "cellurl"=>"ajaxUpdateCYOQuestion.php", "height"=>200, "width"=>950 )); $grid->addCol(array("name"=>"fact"),"last"); // Change some property of the field(s) $grid->setColProperty("CYOQuestionID", array("label"=>"QID", "width"=>30, "sortable"=>true)); $grid->setColProperty("CYOTestQuestionID", array("label"=>"ID", "key"=>true, "width"=>30, "sortable"=>true)); $grid->setColProperty("Title", array("label"=>"Title", "width"=>150, "editable"=>false, "sortable"=>true)); $grid->setColProperty("CuratorReference", array("label"=>"Curator", "width"=>120, "editable"=>true, "sortable"=>true)); $grid->setColProperty("Category", array("label"=>"Category", "width"=>50, "editable"=>true, "sortable"=>true)); $grid->setColProperty("TestType", array("label"=>"Type", "width"=>70, "editable"=>true, "edittype"=>"select", "editoptions"=>array("value"=>"{$types}"), "search"=>false, "sortable"=>true)); $grid->setColProperty("SubTest1", array("label"=>"Subtest 1", "width"=>60, "editable"=>true, "edittype"=>"select", "editoptions"=>array("value"=>"{$subtest1}"), "search"=>false, "sortable"=>true)); $grid->setColProperty("SubTest2", array("label"=>"Subtest 2", "width"=>60, "editable"=>true, "edittype"=>"select", "editoptions"=>array("value"=>"{$subtest2}"), "search"=>false, "sortable"=>true)); $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("fact", array("label"=>"Actions", "width"=>50, "search"=>false)); //$grid->setSubGrid("getQuestionTextFO.php", array('Question'), array(860), array('left')); $loadevent = <<<LOADCOMPLETE function(rowid){ var ids = jQuery("#qfolist").getDataIDs(); for(var i=0;i<ids.length;i++){ var rowd = $("#qfolist").getRowData(ids<em class="d4pbbc-italic"></em>); var cl = ids<em class="d4pbbc-italic"></em>; sh = '<img src="../instance/resources/default/images/view_12x12.png" title="Show question" onclick="javascript:showQuestion('+cl+')" ></ids>'; jQuery("#qfolist").setRowData(ids<em class="d4pbbc-italic"></em>,{fact:sh}); } } LOADCOMPLETE; $grid->setGridEvent("loadComplete",$loadevent); $beforesubmit = <<<BEFORESUBMIT function( rowId, name, val, iRow, iCol ) { var cid = $(this).jqGrid('getCell', rowId, 'CYOTestQuestionID'); return { candid : cid}; } BEFORESUBMIT; $grid->setGridEvent("beforeSubmitCell",$beforesubmit); $grid->callGridMethod('#qavlist','gridDnD', array(array("connectWith"=>"#qavlist,#qfolist,#qtlist"))); $grid->callGridMethod('#qfolist','gridDnD', array(array("ondrop"=>"function (ev, ui, getdata) { var acceptId = \$(ui.draggable).attr('id');}"))); $grid->callGridMethod('#qfolist','sortableRows'); // 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('#qfolist','#qfopager',true, null,null,true,true,true); $conn = null; ?> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top