Skip to content

Integrate phpGrid with MVC based frameworks such as Yii, Symphony, Laravel, Codeignitor, Zend Framework, CakePHP, Joomla, Drupal etc

Solution 1:

The key to integrate phpGrid with MVC framework is to use get_display() method. The method is similar to display() method, but instead render the grid onto the screen, the get_display holds the output in a buffer, so it can be passed between views and controllers. For example:

In your controller, 

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg -> display(false);  // do not render display
$grid = $dg -> get_display(false);  // set to true to include script header

In your view:

// other code in the view.....
echo $grid;

Please note that the display(false) method must be called BEFORE get_display()

Solution 2:

A second working workaround reported by our users is to create a standalone file that contains the phpGrid logic, then using a jQuery call on page load to load that file into a div. 

Below are some integration example in Codeigniter:

Official Laravel Bootstrap Integration:


Comprehensive phpGrid Laravel Bootstrap Integration:
http://phpgrid.com/example/phpgrid-laravel-5-twitter-bootstrap-3-integration/

Feedback and Knowledge Base