Hi will
Many thanks for your prompt reply. Unfortunately dropping your code in (or inserting the js:) does not seem to be firing in as much as no alert box pops up.
Any other ideas please.
Hi Will, basically we need to intercept the process before a grid reload. beforeRequest does this but only on the first creation of the grid and we need to do it any time the grid is to be refreshed, reloaded, searched etc. Is there a method we can invoke to do this. Many thanks.
Quite right, many thanks.
Hi Will
I am confused as to what I should be setting the various elements to. I have:
$grid->setColProperty("activeAfter", array("label"=>"Active after", "width"=>30, "hidden"=>true, "searchoptions"=>array("searchhidden"=>true, "sopt"=>array("ge")), "formatter"=>"date", "sorttype"=>"date", "formatoptions"=>array( "srcformat"=>'Y-m-d', "newformat"=>'d/m/Y')));
and
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// Set the datepicker. Note that the script automatically // converts the user date set in the jqGrid $grid->setDatepicker('activeBefore', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); $grid->setDatepicker('activeAfter', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); $grid->setDatepicker('FinishedAt', array("showOn"=>"focus","altFormat"=>"Y-m-d"), true, true); //$grid->datearray = array('CreatedAt'); // Finally set the database setting for the date $grid->setUserTime("Y-m-d H:i:s"); $grid->SetUserDate("Y-m-d H:i:s"); $grid->setDbDate("Y-m-d H:i:s"); $grid->setDbTime("Y-m-d H:i:s"); $grid->datearray = array('activeBefore','activeAfter','FinishedAt'); |
Selecting 10th May 2017 in the data picker in the search dialog displays 10/5/2017 in the search dialog. Checking the $_REQUEST after the search gives
[filters] => {"groupOp":"AND","rules":[{"field":"activeAfter","op":"ge","data":"10/05/2017"}]}
How do I get this to be 2017-05-10 at this point.
Many thanks
Thank you for your prompt response.
I already have recreateFilter set to true as in
|
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 |
$grid->navigator=true; $grid->setNavOptions('navigator',array( "refresh"=>true, "excel"=>false, "add"=>false, "edit"=>false, "del"=>false, "view"=>false, "multipleSearch"=>true, "multipleGroup"=>true, "recreateFilter"=>true )); $grid->setNavOptions('search',array( "drag"=>false, "caption"=>translator_get_text("Search...","UserUI_Candidate"), "Find"=>translator_get_text("Search","UserUI_Candidate"), "Reset"=>translator_get_text("Show All","UserUI_Candidate"), "addrule"=>translator_get_text("Add search criteria","UserUI_Candidate"), "delrule"=>translator_get_text("Remove search criteria","UserUI_Candidate"), "closeOnEscape"=>true, "searchOnEnter"=>true, "closeAfterSearch"=>true ) ); |
but it appears the filters are not being cleared.
Regards
Murray
We would like the ability to have the search dialog across the top above the grid and have it permanently visible. I know we can put search/filter boxes in the toolbar but these would not work with the hidden fields on which we search. We could do this using javascript but are interested in building it in the php code we use to build the grid.
Thank you Tony, that works well.
Hi Tony
Thank you for the response. Just to clarify; are you saying this ability to drag, drop and sort is only available between containers but not in jqGrid or should code like the following work with between grids. ie. using the something like the following
|
1 2 3 4 5 6 7 8 9 |
$sort = <<< SORTABLE $( function() { $( "#fixedorderlist, #randomorderlist" ).sortable({ connectWith: ".connectedSortable" }).disableSelection(); } ); SORTABLE; $grid->setJSCode($sort); |
instead of
|
1 2 3 |
$dragdropf = <<< DRAGF jQuery('#fixedorderlist').jqGrid('gridDnD', {connectWith:'#randomorderlist', ........... |
Hi Tony
In grid B I have tried, without success
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$dragdropf = <<< DRAGF jQuery('#B').jqGrid('gridDnD', {connectWith:'#C', ondrop: function(evt, obj, data){ data.droppedon=evt.target.id; data.testid={$id}; $.ajax({ method: "POST", url: "ajaxAddLink.php", data: data, success: (function(){ $('#C').trigger( 'reloadGrid' ); $('#B').trigger( 'reloadGrid' ); }) }) } } ); DRAGF; $grid->setJSCode($dragdropf); $grid->callGridMethod('#B','sortableRows'); |
It does the same thing of allowing drag from A to B, A to C, B to C and C to B but not allow reordering the rows in B.
Regards
Murray
Resolved by using
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$dragdropf = <<< DRAGF jQuery('#fixedorderlist').jqGrid('gridDnD',{connectWith:'#randomorderlist', ondrop: function(evt, obj, data){ $.ajax({ method: "POST", url: "ajaxAddLink.php", data: data }) } }); DRAGF; $grid->setJSCode($dragdropf); |
Hi Will, thank you for your time on this. I have got it working by using
“cellEdit”=>true,
“cellsubmit”=>”remote”,
“cellurl”=>”……….php”,
with
|
1 2 3 4 5 6 7 |
$beforesubmit = <<<BEFORESUBMIT function( rowId, name, val, iRow, iCol ) { var cid = $(this).jqGrid('getCell', rowId, 'CYOTestQuestionID'); return { candid : cid}; } BEFORESUBMIT; $grid->setGridEvent("beforeSubmitCell",$beforesubmit); |
Hi Will, Compliments of the Season to you. The beforeSubmitCell works well to get the relevant values, however it appears the setAfterCrudAction function is not happening. I have debug on and only see the SELECT statements, no UPDATE.
|
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 |
// Change some property of the field(s) $grid->setColProperty("CYOQuestionID", array("label"=>"QID", "width"=>30, "sortable"=>true)); $grid->setColProperty("CYOTestQuestionID", array("label"=>"ID", "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("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<em class="d4pbbc-italic"></em>); var cl = ids<em class="d4pbbc-italic"></em>; st = '<img src="../instance/resources/default/images/view_12x12.png" title="Show question" onclick="javascript:showQuestion('+cl+')" ></ids>'; jQuery("#qtlist").setRowData(ids<em class="d4pbbc-italic"></em>,{tact:st}); } } LOADCOMPLETE; $grid->setGridEvent("loadComplete",$loadevent); $beforesubmit = <<<BEFORESUBMIT function( rowId, name, val, iRow, iCol ) { var cid = $(this).jqGrid('getCell', rowId, 'CYOTestQuestionID'); return { CYOTestQuestionID : cid}; } BEFORESUBMIT; $grid->setGridEvent("beforeSubmitCell",$beforesubmit); // This command is executed after edit $id = jqGridUtils::GetParam('id'); $cid = jqGridUtils::GetParam('CYOTestQuestionID'); $tType = jqGridUtils::GetParam('TestType'); $grid->setAfterCrudAction('edit', "UPDATE tr_cyotestquestion SET TestTypeID = ? WHERE CYOTestQuestionID = ?",array($tType,$cid)); |
$tType and $cid do contain the correct numbers at this stage. I cannot see how this differs from the examples in the documentation.
Regards
Murray
Is there any way to get data from other columns in a row in which a cell is edited in addition to the rowid and the value of the newly edited cell ?
This is the complete code
|
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 |
<?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); // 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 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); // 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, "sortable"=>true)); $grid->setColProperty("CYOTestQuestionID", array("label"=>"ID", "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("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<em class="d4pbbc-italic"></em>); var cl = ids<em class="d4pbbc-italic"></em>; st = '<img src="../instance/resources/default/images/view_12x12.png" title="Show question" onclick="javascript:showQuestion('+cl+')" ></ids>'; jQuery("#qtlist").setRowData(ids<em class="d4pbbc-italic"></em>,{tact:st}); } } LOADCOMPLETE; $grid->setGridEvent("loadComplete",$loadevent); // This command is executed after edit $cid = jqGridUtils::GetParam('CYOTestQuestionID'); $tType = jqGridUtils::GetParam('TestType'); $grid->setAfterCrudAction('edit', "update tr_cyotestquestion set TestTypeID = ? WHERE CYOTestQuestionID=?",array($tType,$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; ?> |
Further to the above. Is there any way to have the column names in the subGrid different from the column names. For example instead of ‘Licence Start’ in the sub grid have the same wording but translated into another language.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top