include grid in PHP

Questionsinclude grid in PHP
SirShadow asked 10 years ago

I'm trying to include the grid in a webpage but I'm facing an error. Actually the Grid is shown without data with an Error subwindow which displays the page (again inside) with the data as an array. I'm sure that I'm doing something wrong but what?

The structure is something like this:
Index (with HTML head) <- calling function to check login {
calling function to display different things {
include(grid.php[only the php part])
}
}
I'm using absolute path as links to files:
Path of index = dirname(__FILE__).'/';
Path to jqgrid_dist.php = Path of index + Path to directory (relative to index)
When I'm putting again the HTML code (<head> things and <div>s) in grid.php and go directly to grid.php (not through index) the grid is shown ok.

3 Answers
Abu Ghufran answered 10 years ago

Also 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

For eg. You can divide code in 2 sections. And put first in controller and pass the $out variable to view, where you can render it with rest of JS/CSS files.

CONTROLLER PART

include("inc/jqgrid_dist.php");
$g = new jqgrid();
…..
$out = $g->render("list1");

VIEW PART

<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>

SirShadow answered 10 years ago

Thanks a lot. I followed your instruction and now it's ok and running very well.
Congrats for what are you doing.

C3media answered 10 years ago

Hi… ¿It's possible to insert phpgrid in joomla site?

Your Answer

12 + 8 =

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?