Version 1.4.7
Following the lead from the subgrid_detail.php demo file, I used:
$c_id = $_REQUEST["rowid"];
if (empty($c_id)) $c_id = 0;
Then my SQL used ' WHERE mKey = $c_id '
Watching MySQL General Log, I see two queries. The first (edited) is:
SELECT …… FROM … WHERE myKey = 0 LIMIT 1 OFFSET 0
And the second is:
SELECT …… FROM … WHERE myKey = 148 LIMIT 1 OFFSET 0
The subgrid shows no results. I was wondering if the double-query is the cause?
Here is the redacted code:
//Connect to mysql server
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$conn) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
mysql_select_db(DB_DATABASE);
include("./inc/jqgrid_dist.php");
$c_id = $_REQUEST["rowid"];
if (empty($c_id)) $c_id = 0;
$g = new jqgrid();
$col = array();
$col[".."] = "…."; // caption of column
…….
$cols[] = $col;
// –> other $col followed
$g->set_options($grid);
$g->set_actions(array(
"add"=>false, // allow/disallow add
"edit"=>true, // allow/disallow edit
"delete"=>false, // allow/disallow delete
"rowactions"=>false, // show/hide row wise edit/del/save option
"export"=>false, // show/hide export to excel option
"autofilter" => false, // show/hide autofilter for search
"search" => "simple" // show single/multi field search condition (e.g. simple or advance)
)
);
// you can provide custom SQL query to display data
$g->select_command = "SELECT …… FROM … mKey = $c_id";
// this db table will be used for add,edit,delete
$g->table = "…";
// pass the cooked columns to grid
$g->set_columns($cols);
// generate grid output, with unique grid name as 'list1'
$out2 = $g->render("sub1".$_REQUEST["subgrid"]);
echo $out2;
Just to log answer for others …
I changed few lines in subgrid.php, perhaps it is working now as expected.
…old…
include("./inc/jqgrid_dist.php");
// passed from parent grid
//$tKey = $_POST["tKey"];
$tKey = $_REQUEST['tKey'];
$g = new jqgrid();
…new…
include("./inc/jqgrid_dist.php");
// passed from parent grid
if (!empty($_POST["tKey"]))
$_SESSION["tKey"] = $_POST['tKey'];
$tKey = $_SESSION['tKey'];
$g = new jqgrid();
I am using purchased version. When I tried main grid with
$g->set_columns($cols); sub grid doesn't display any more. If I remove this I lose all formatting on main grid columns and it does work correctly.
Hiren, can you send me your grid code file at [email protected]
This looks like some php syntax or parse error issue.