Grid failing to load

QuestionsGrid failing to load
Ghaleb Dweikat asked 10 years ago

Hello,

I tried out this grid and the sample codes work perfectly fine. However whenever I try to include them into my project it basically doesn't show the data inside the grid but instead pops it out in json format in an error popup.

the file in question is:
<?php

include('Header.php');

// include db config
include_once("config.php");

// set up DB
mysql_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS);
mysql_select_db(PHPGRID_DBNAME);

// include and create object
include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");

$g = new jqgrid();

$grid["rowNum"] = 10; // by default 20
$grid["sortname"] = 'ID'; // by default sort grid by this field
$grid["sortorder"] = "ASC"; // ASC or DESC
$grid["caption"] = "Invoice Data"; // caption of grid
$grid["autowidth"] = true; // expand grid to screen width
$grid["multiselect"] = true; // allow you to multi-select through checkboxes

$grid["altRows"] = true;
$grid["altclass"] = "myAltRowClass";

$grid["rowactions"] = true; // allow you to multi-select through checkboxes

// export XLS file
// export to excel parameters
$grid["export"] = array("format"=>"pdf", "filename"=>"my-file", "sheetname"=>"test");

// RTL support
// $grid["direction"] = "rtl";

$g->set_options($grid);

$g->set_actions(array(
"add"=>false, // allow/disallow add
"edit"=>true, // allow/disallow edit
"delete"=>true, // allow/disallow delete
"rowactions"=>true, // show/hide row wise edit/del/save option
"export"=>true, // show/hide export to excel option
"autofilter" => true, // show/hide autofilter for search
"search" => "advance" // 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 Players";

// this db table will be used for add,edit,delete
$g->table = "Players";

// generate grid output, with unique grid name as 'list1'
$out = $g->render("MyList");

?>
<div style="margin:10px">
<table style="width: 100%;">
<tr style="">
<td style="width: 20%; vertical-align: top;">
<div class="ListItem">
<a href="Rankings.php?Type=IndividualKills">Individual Kills</a>
</div>
<div class="ListItem">
<a href="Rankings.php?Type=GuildKills">Guild Kills</a>
</div>
<div class="ListItem">
<a href="Rankings.php?Type=PlayersList">Players List</a>
</div>
<div class="ListItem">
<a href="Rankings.php?Type=IndividualKills">Others</a>
</div>
<div class="ListItem">
<a href="Rankings.php?Type=IndividualKills">Others</a>
</div>

</td>
<td>
<?php echo $out?>

</td>
</tr>
</table>

</div>

<?php

include('Footer.php');

?>

The header.php contains all the links and refs needed:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="/lib/js/themes/dot-luv/jquery-ui.custom.css"></link>
<link rel="stylesheet" type="text/css" media="screen" href="/lib/js/jqgrid/css/ui.jqgrid.css"></link>

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

<meta charset="UTF-8">
<title>Aika Online Private Servers!</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>

<div id="page">
<div id="header"> …etc

Am I doing something wrong? or is there an issue?

Live link (Faulty page): http://aika.azurewebsites.net/Rankings.php
Live Link (Working demo): http://aika.azurewebsites.net/demos/appearence/alternate-row2.php

2 Answers
Abu Ghufran answered 10 years ago

Make sure, you call '$g->render();' function before any HTML is rendered
(echo'd) to output, as it expect exact JSON format for ajax calls. You can echo the output of render() function to desired location in html.

Include header.php after render function.

$out = $g->render("MyList");

include('Header.php');
?>
<div style="margin:10px">
<table style="width: 100%;">

Ghaleb Dweikat answered 10 years ago

Thanks, works great now 😀

I also sent a message on google+ you can discard that 😀

Your Answer

12 + 6 =

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?