SubGrid – Double Queries, the first one, no results, second is correct

QuestionsSubGrid – Double Queries, the first one, no results, second is correct
G. Nalu asked 6 years ago

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?

5 Answers
Abu Ghufran answered 6 years ago

Can you share some php files. Very difficult to tell with this data.

G. Nalu answered 6 years ago

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;

Abu Ghufran answered 6 years ago

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();

hiren kothari answered 6 years ago

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.

Abu Ghufran answered 6 years ago

Hiren, can you send me your grid code file at [email protected]
This looks like some php syntax or parse error issue.

Your Answer

11 + 11 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!