APYDataGridBundle is a Symfony bundle for create grids for list your Entity (ORM), Document (ODM) and Vector (Array) sources. APYDataGridBundle was initiated by Stanislav Turza (Sorien) and inspired by Zfdatagrid and Magento Grid.
You can see CHANGELOG and UPGRADE 2.0.
This version of the bundle requires Symfony 3.0+.
If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.
# app/config/config.yml
framework:
translator: ~
For more information about translations, check Symfony documentation.
Require the bundle with composer :
$ composer require apy/datagrid-bundle
Composer will install the bundle to your project's vendor/apy/datagrid-bundle directory.
Enable the bundle in the kernel :
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new APY\DataGridBundle\APYDataGridBundle(),
// ...
);
}
<?php
namespace MyProject\MyBundle\Controller;
use APY\DataGridBundle\Grid\Source\Entity;
class DefaultController extends Controller
{
public function myGridAction()
{
// Creates a simple grid based on your entity (ORM)
$source = new Entity('MyProjectMyBundle:MyEntity');
// Get a Grid instance
$grid = $this->get('grid');
// Attach the source to the grid
$grid->setSource($source);
// Return the response of the grid to the template
return $grid->getGridResponse('MyProjectMyBundle:myGrid.html.twig');
}
}
<?php
namespace MyProject\MyBundle\Entity
use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;
/**
* @GRID\Source(columns="id, my_datetime")
*/
class MyEntity
{
/*
* @ORM\Column(type="integer")
*/
protected $id;
/*
* @ORM\Column(type="datetime")
*/
protected $my_datetime;
}
<!-- MyProject\MyBundle\Resources\views\myGrid.html.twig -->
{{ grid(grid) }}
Don't forget to clean your cache !
Now you have completed the basic installation and configuration of the APYDataGridBundle, you are ready to learn about more advanced features and usages of the bundle.
The following documents are available :