Hi, I am attempting to create subgrid setup between my tables plant (parent) and research (sub grid) in Guriddo Suito. I am able to see the plant table with a plus icon for the subgrid — just no information in the grid appears only a ^ next to the subgrid area and the plus changes to a minus.
My three files are myjqgridphp.php which contains the html from the example on your website for “Sub Grid (2 nested levels)” and my files grid.php and subgrid.php which I have modified as below. I have installed and am connected to the northwind database and ran it as the demo and get the same problem – only the customer data shows up. I am assuming it is something in the subgrid file or elsewhere that I do not have configured properly but I am enclosing both subgrid.php and grid.php below and would be happy to post any other files if you could please help. Thank you.
GRID.PHP
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 |
<?php require_once 'jq-config.php'; // include the jqGrid Class require_once "php/PHPSuito/jqGrid.php"; // include the driver class require_once "php/PHPSuito/DBdrivers/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT idplant, name, latin_name, other_name FROM plant'; // Set the table to where you update the data $grid->table = 'plant'; // set the ouput format to json $grid->dataType = 'json'; // Let the grid create the model $grid->setColModel(); // Set the url from where we obtain the data $grid->setUrl('grid.php'); // Set grid caption using the option caption $grid->setGridOptions(array( "caption"=>"testing", "rowNum"=>10, "sortname"=>"idplant", "hoverrows"=>true, "rowList"=>array(10,20,50), )); $grid->setColProperty('idplant', array("label"=>"ID", "width"=>50)); $grid->setSubGridGrid("subgrid.php"); // Enable navigator $grid->navigator = true; // Enable only editing $grid->setNavOptions('navigator', array("excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>false)); // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); |
SUBGRID.PHP
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 |
<?php require_once 'C/mamp/htdocs/jq-config.php'; // include the jqGrid Class require_once ABSPATH."php/PHPSuito/jqGrid.php"; // include the driver class require_once ABSPATH."php/PHPSuito/DBdrivers/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 $conn->query("SET NAMES utf8"); // Get the needed parameters passed from the main grid // By default we add to postData subgrid and rowid parameters in the main grid $oper = jqGridUtils::GetParam("oper"); $subtable = jqGridUtils::GetParam("subgrid"); $rowid = jqGridUtils::GetParam("rowid"); //if(!$subtable && !$rowid) die("Missed parameters"); // Create the jqGrid instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = "SELECT idresearch, Article, Citation, dateadded, plant_idplant FROM research WHERE plant_idplant = ?"; // set the ouput format to json $grid->dataType = 'json'; $grid->setPrimaryKeyId('idresearch'); // Let the grid create the model $grid->setColModel(null,array($rowid)); // Set the url from where we obtain the data $grid->setUrl('subgrid.php'); $onselrow = <<< ONSELROW function(rowid, selected) { if(rowid && rowid !== lastSelection) { $(this).jqGrid('restoreRow', lastSelection); $(this).jqGrid('editRow', rowid, true); lastSelection = rowid; } } ONSELROW; $grid->setGridEvent('onSelectRow', $onselrow); $grid->table = 'research'; $grid->setColProperty('idresearch', array( "editable"=>false )); $grid->setColProperty('plant_idplant', array( "hidden"=>true )); // Set some grid options $grid->setGridOptions(array( "width"=>540, "rowNum"=>10, "sortname"=>"idresearch", "height"=>110, "postData"=>array("subgrid"=>$subtable,"rowid"=>$rowid))); // Change some property of the field(s) $grid->setDbTime('Y-m-d H:i:s'); $grid->setUserTime('m/d/Y'); $grid->setDatepicker("dateadded"); $grid->setColProperty("dateadded", array( "formatter"=>"date", "formatoptions"=>array("reformatAfterEdit"=>true, "srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y"), "search"=>false ) ); // Enjoy $subtable = $subtable."_t"; $pager = $subtable."_p"; $grid->renderGrid($subtable,$pager, true, null, array(&$rowid), true,true); |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top