Does innerHTML work for phpgrid?
In index.php, I create 2 grids.
<?php
include(“../lib/inc/jqgrid_dist.php”);
include_once(“config/config.php”);
$db_conf = array(
“type” => PHPGRID_DBTYPE,
“server” => PHPGRID_DBHOST,
“user” => PHPGRID_DBUSER,
“password” => PHPGRID_DBPASS,
“database” => PHPGRID_DBNAME
);
$grid = new jqgrid($db_conf);
$opt[“caption”] = “Article”;
$opt[“width”] = 1600;
$grid->set_options($opt);
$grid->table = “Article”;
$out_0 = $grid->render(“list1”);
// second grid
$grid = new jqgrid($db_conf);
$opt[“caption”] = “Country”; // caption of grid
$opt[“width”] = 1600;
$grid->set_options($opt);
$grid->table = “Country”;
$out_1 = $grid->render(“list2”);
?>
In the <body>, they are displayed in 2 tabs.
<div id=”gridtabs”>
<ul>
<li><a class=”tabitems” id=”item0″ href=”#tabs-0″>Grid0</a></li>
<li><a class=”tabitems” id=”item1″ href=”#tabs-1″>Grid1</a></li>
</ul>
<div id=”tabs-0″>
<div id=”out_report_0″>
<?php echo $out_0; ?>
</div>
</div>
<div id=”tabs-1″>
<div id=”out_report_1″>
<?php echo $out_1; ?>
</div>
</div>
</div>
An event calls a JavaScript function, which, via Ajax, is sent to a PHP function.
function createReport() {
global $db_conf;
$grid = new jqgrid($db_conf);
$opt[“caption”] = “Customers”;
$opt[“width”] = 600;
$grid->set_options($opt);
$grid->table = “Customers”;
$report = $grid->render(“list3”);
return $report;
}
The returned $report in onDone(s):
function onDone(s)
{
document.getElementById(“out_report_0”).innerHTML = s;
}
The grid $out_0 disappears on tabs-0, and …nothing appears!
Tried not creating a new grid but copying $out_1 from tabs-1 to tabs-0.
Again, nothing…
In createReport(), changed return $report; to:
ob_start();
echo $report;
$reportHTML = ob_get_clean();
return $reportHTML;
Again, nothing…
What am I doing wrong?
Thank you for any advice!
Hello,
I’ve tested loading grid via ajax in a div using jquery.
Refer this code:
https://gist.github.com/gridphp/c85ee8db525ae46de40b118718fca241#file-master-detail-ajax-php-L38