Datagrid for Symfony2 inspired by Zfdatagrid and Magento Grid but not compatible.
Compatibility: Symfony 2.x
The following documents are available:
- Abhoryo
- golovanov
- touchdesign
- Spea
- nurikabe
- and all bug reporters
// MyProject\MyBundle\DefaultController.php
namespace MyProject\MyBundle\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sorien\DataGridBundle\Grid\Source\Entity;
use Sorien\DataGridBundle\Grid\Source\Document;
class DefaultController extends Controller
{
public function myGridAction()
{
// Creates simple grid based on your entity (ORM)
$source = new Entity('MyProjectMyBundle:MyEntity');
// or use Document source class for ODM
$source = new Document('MyProjectMyBundle:MyDocument');
$grid = $this->get('grid');
// Mass actions, query and row manipulations are defined here
$grid->setSource($source);
// Columns, row actions are defined here
if ($grid->isReadyForRedirect())
{
// Data are stored, do redirect to prevent multiple post requests
return new RedirectResponse($grid->getRouteUrl());
}
else
{
// To obtain data for template simply pass in the grid instance
return $this->render('MyProjectMyBundle::my_grid.html.twig', array('data' => $grid));
}
}
}
<!-- MyProject\MyBundle\Resources\views\my_grid.html.twig -->
{{ grid(data) }}