The Unofficial Selection
KnpLabs is hiring
Symfony2 developers!

Infos

Keywords

datagrid

Score evolution

Score details ( ? )

  • Github Followers: 70
  • Last 30 days activity: 2.6
  • README file size: 5
  • Uses Travis CI: 0
  • Travis CI build status: 0
  • Provides a composer package: 5
  • KnpBundles recommendations: 10

Latest commits

  • [BC Break] Show a message instead of an empty grid
    By Abhoryo 17 days ago
  • Fix Source mapping after the last commit
    By Abhoryo 18 days ago
  • Fix initFilters + Add initOrder method
    By Abhoryo 18 days ago
  • Fix variable name
    By Abhoryo 18 days ago
  • Add show and hide columns methods
    By Abhoryo 18 days ago
  • fix render bloc ids and manipulate row field ids with mapping fields.
    By Abhoryo 18 days ago
  • optimize persistence detection
    By Abhoryo 18 days ago
  • [BC BREAK] Don't use previous data if the client leave the page during the session. You can turn on the persistence if you want the opposite.
    By 18 days ago
  • Fix createHash when you define a id for the grid + changelog
    By 18 days ago
  • Fix createHash when you define a id for the grid + changelog
    By 18 days ago
96

DataGridBundle by S0RIEN

Symfony2 Datagrid Bundle

Getting Started With DataGridBundle

Datagrid for Symfony2 inspired by Zfdatagrid and Magento Grid but not compatible.

Compatibility: Symfony 2.x

The following documents are available:

  1. Installation
  2. Grid Configuration
  3. Columns Configuration via annotations
  4. Multiple grids
  5. Overriding Templates

Special thanks to all contributors

Abhoryo, golovanov, touchdesign, Spea, nurikabe, print, Gregory McLean, centove, lstrojny, Benedikt Wolters, Martin Parsiegla, evan and all bug reporters

Simple grid with ORM or ODM as source

// 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));
        }
    }
}

Rendering inside twig

<!-- MyProject\MyBundle\Resources\views\my_grid.html.twig -->
{{ grid(data) }}

Working preview with assets

Screenshot

  • 2012-02-15 Blair W

    Quick question, if you were to use a entity as the data source for the grid and you wanted to display two different sets of columns on the same page or on a different page, would this be possible?