Hi,
Can I integrate phpgrid with Laravel framework. If Yes, can you send some basic example.
Hello,
The example would be little difficult now, but here is how it works.
PHP Grid works independently from the framework lib and don't use data access layers of framework.
To integrate in MVC, 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
<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>
…
I tried this but getting error "Couldn't execute query. No database selected ". How do I set the connection to use from the framework.
I managed to get the DB part working, but when I try to update any data,the framework throws HttpNotAllowed exception. It is because of the routes mechanism defined in the framework. Any way to fix this?
I'm also having this problem. The table is loading fine but I can't edit because of the HttpNotAllowed exception.
Ok, so I solved it by adding a POST route to the page. The MethodNotAllowed exception happens because phpgrid is trying to post to a GET only page. So I made a POST route for my page and it is fine!
There still so much to do for the grid to work with Laravel. Laravel needs to pass in a token with every POST. So how do we intercept the POST to add the data, value pair _token = 'xxxxxx' to the post data?
Nevermind. I found my answer here:
http://laravel.io/forum/03-30-2015-how-to-submit-form-via-ajax-in-laravel-5