Error message and no data in grid

QuestionsError message and no data in grid
Friency Fernandez asked 8 years ago

Hi. I get an error which has this written on a popup:
{"page":1,"total":1,"records":"3","rows":[{"InventoryID":"1","IngredientsID":"1","IngredientsInvQty":"100","IngredientTypeID":"2"},{"InventoryID":"1","IngredientsID":"3","IngredientsInvQty":"100","IngredientTypeID":"2"},{"InventoryID":"2","IngredientsID":"2","IngredientsInvQty":"100","IngredientTypeID":"2"}]}
Close

The grid displays but there are no data too. Here is my code
include_once("../phpgrid/config.php");

$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = PHPGRID_DBHOST; // or you mysql ip
$db_conf["user"] = PHPGRID_DBUSER; // username
$db_conf["password"] = PHPGRID_DBPASS; // password
$db_conf["database"] = PHPGRID_DBNAME; // database

// include and create object
include("../phpgrid/lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);

$grid["caption"] = "Inventory";
$grid["autowidth"] = true;
$grid["sortable"] = true;
$g->set_options($grid);
$g->table = "inventory_t";

$out = $g->render("inventory");
echo $out;

Here is the config file
<?php

define("PHPGRID_DBTYPE","mysqli");
define("PHPGRID_DBHOST","localhost");
define("PHPGRID_DBUSER","root");
define("PHPGRID_DBPASS","password");
define("PHPGRID_DBNAME","cakeshopdb");

// Basepath for lib
define("PHPGRID_LIBPATH",dirname(__FILE__).DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR);

?>

1 Answers
Abu Ghufran answered 8 years ago

Looks like some HTML or white space characters are echo'd before calling render() function.

The code structure should be like:
<?php

include("inc/jqgrid_dist.php");
$g = new jqgrid();

$out = $g->render("list1");
?>
and after PHP code, there will be start of html part:

e.g.
<!doctype html>
<html>

<link rel="stylesheet" type="text/css" media="screen" href="js/themes/redmond/jquery-ui.custom.css"></link>
<link rel="stylesheet" type="text/css" media="screen" href="js/jqgrid/css/ui.jqgrid.css"></link>

<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>

<div style="margin:10px">
<?php echo $out?>
</div>

Your Answer

4 + 4 =

Login with your Social Id:

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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?