PHPackages                             lososoid/data-grid-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. lososoid/data-grid-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

lososoid/data-grid-bundle
=========================

Symfony DataGridBundle

v2.5.5(8y ago)023MITPHPPHP &gt;=5.3.2

Since May 21Pushed 8y agoCompare

[ Source](https://github.com/lososoid/KitpagesDataGridBundle)[ Packagist](https://packagist.org/packages/lososoid/data-grid-bundle)[ Docs](https://github.com/kitpages/KitpagesDataGridBundle)[ RSS](/packages/lososoid-data-grid-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (13)Versions (35)Used By (0)

KitpagesDataGridBundle
======================

[](#kitpagesdatagridbundle)

[![Build Status](https://camo.githubusercontent.com/e366f99de44adaa0da4bf2d6d2bc035af1ed806bb488173792e12e5203c22e1f/68747470733a2f2f7472617669732d63692e6f72672f6b697470616765732f4b69747061676573446174614772696442756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/kitpages/KitpagesDataGridBundle)

[![SensioLabsInsight](https://camo.githubusercontent.com/2649c506cabb869a67ddf01d91cd5ca0f348e864601cdfa1afb7d76f43d6cfa9/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64663039656431302d346336312d346231642d386366372d3532303639303134393363342f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/df09ed10-4c61-4b1d-8cf7-5206901493c4)

This Symfony2 Bundle is a simple datagrid bundle. It aims to be easy to use and extensible.

Warning version 2
-----------------

[](#warning-version-2)

Version 2 is here. You can switch to branch 1.x (or tags 1.x) if you want to stay on legacy version. There are BC Breaks between version 1 and version 2.

Actual state
============

[](#actual-state)

- v1.x is stable, production ready
- v2.x is stable and production ready
- v2.5.x is following version 2.5.x of doctrine
- v2.4.x is following version 2.4.x of doctrine

Features
========

[](#features)

- Display a Data Grid from a Doctrine 2 Query Builder
- Automatic filter
- Sorting on columns
- Easy to configure
- Easy to extend
- Documented (in this readme for basics and in Resources/doc for advanced topics)
- Paginator can be used as a standalone component
- Change of DataGrid behaviour with events
- Change of DataGrid presentation with twig embeds

System Requirement
==================

[](#system-requirement)

- jQuery has to be present on your pages
- version 1.8+ of twig is mandatory (use of twig embeds)

Documentation
=============

[](#documentation)

The documentation is in this README and in [Resources/doc](https://github.com/kitpages/KitpagesDataGridBundle/tree/master/Resources/doc)

- [Installation and simple user's guide : In this README](#installation)
- [Grid Extended Use](https://github.com/kitpages/KitpagesDataGridBundle/tree/master/Resources/doc/10-GridExtendedUse.md)
- [Standalone Paginator](https://github.com/kitpages/KitpagesDataGridBundle/tree/master/Resources/doc/20-StandalonePaginator.md)
- [Events for extended use case](https://github.com/kitpages/KitpagesDataGridBundle/tree/master/Resources/doc/30-Events.md)

Installation
============

[](#installation)

You need to add the following lines in your deps :

Add KitpagesChainBundle in your composer.json

```
{
    "require": {
        "kitpages/data-grid-bundle": "~2.4" // Use ~2.5 if you use doctrine >= 2.5
    }
}
```

Now tell composer to download the bundle by running the step:

```
$ php composer.phar update kitpages/data-grid-bundle
```

AppKernel.php

```
$bundles = array(
    ...
    new Kitpages\DataGridBundle\KitpagesDataGridBundle(),
);
```

Configuration in config.yml
===========================

[](#configuration-in-configyml)

These values are default values. You can skip the configuration if it is ok for you.

```
kitpages_data_grid:
    grid:
        default_twig: KitpagesDataGridBundle:Grid:grid.html.twig
    paginator:
        default_twig: KitpagesDataGridBundle:Paginator:paginator.html.twig
        item_count_in_page: 50
        visible_page_count_in_paginator: 5
```

Note you can use the followin configuration in order to user Bootstrap 3 :

```
kitpages_data_grid:
    grid:
        default_twig: KitpagesDataGridBundle:Grid:bootstrap3-grid.html.twig
    paginator:
        default_twig: KitpagesDataGridBundle:Paginator:bootstrap3-paginator.html.twig
```

Simple Usage example
====================

[](#simple-usage-example)

In the controller
-----------------

[](#in-the-controller)

```
use Kitpages\DataGridBundle\Grid\GridConfig;
use Kitpages\DataGridBundle\Grid\Field;
use Symfony\Component\HttpFoundation\Request;

class ContactController
{
    public function productListAction(Request $request)
    {
        // create query builder
        $repository = $this->getDoctrine()->getRepository('AcmeStoreBundle:Product');
        $queryBuilder = $repository->createQueryBuilder('item')
            ->where('item.price > :price')
            ->setParameter('price', '19.90')
        ;

        $gridConfig = new GridConfig();
        $gridConfig
            ->setQueryBuilder($queryBuilder)
            ->setCountFieldName('item.id')
            ->addField('item.id')
            ->addField('item.slug', array('filterable' => true))
            ->addField('item.updatedAt', array(
                'sortable' => true,
                'formatValueCallback' => function($value) { return $value->format('Y/m/d'); }
            ))
        ;

        $gridManager = $this->get('kitpages_data_grid.grid_manager');
        $grid = $gridManager->getGrid($gridConfig, $request);

        return $this->render('AppSiteBundle:Default:productList.html.twig', array(
            'grid' => $grid
        ));
    }
}
```

Twig associated
---------------

[](#twig-associated)

In your twig you just have to put this code to display the grid you configured.

```
{% embed kitpages_data_grid.grid.default_twig with {'grid': grid} %}
{% endembed %}

```

More advanced usage
===================

[](#more-advanced-usage)

In the controller
-----------------

[](#in-the-controller-1)

same controller than before

Twig associated
---------------

[](#twig-associated-1)

If you want to add a column on the right of the table, you can put this code in your twig.

```
{% embed kitpages_data_grid.grid.default_twig with {'grid': grid} %}

    {% block kit_grid_thead_column %}
        Action
    {% endblock %}

    {% block kit_grid_tbody_column %}
        Edit
    {% endblock %}

{% endembed %}

```

More advanced usage
===================

[](#more-advanced-usage-1)

In the controller
-----------------

[](#in-the-controller-2)

```
use Kitpages\DataGridBundle\Grid\GridConfig;
use Kitpages\DataGridBundle\Grid\Field;
use Symfony\Component\HttpFoundation\Request;

class AdminController extends Controller
{

    public function listAction(Request $request, $state)
    {
        // create query builder
        $em = $this->get('doctrine')->getEntityManager();
        $queryBuilder = $em->createQueryBuilder()
            ->select('m, e, c')
            ->from('KitappMissionBundle:Mission', 'm')
            ->leftJoin('m.employee', 'e')
            ->leftJoin('m.client', 'c')
            ->where('m.state = :state')
            ->add('orderBy', 'm.updatedAt DESC')
            ->setParameter('state', $state)
        ;

        $gridConfig = new GridConfig();
        $gridConfig
            ->setQueryBuilder($queryBuilder)
            ->setCountFieldName("m.id");
            ->addField('m.title', array('label' => 'title', 'filterable' => true))
            ->addField('m.country', array('filterable' => true))
            ->addField('c.corporation', array('filterable' => true))
            ->addField('e.lastname', array('filterable' => true))
            ->addField('e.email', array('filterable' => true))
        ;

        $gridManager = $this->get('kitpages_data_grid.grid_manager');
        $grid = $gridManager->getGrid($gridConfig, $request);

        return $this->render('KitappMissionBundle:Admin:list.html.twig', array(
            'grid' => $grid
        ));
    }
}
```

Twig associated
---------------

[](#twig-associated-2)

same Twig than before

Field "as"
==========

[](#field-as)

For request like

```
$queryBuilder->select("item, item.id * 3 as foo");

```

You can display the foo field with

```
$gridConfig->addField("item.id");
$gridConfig->addField("foo");

```

Events
======

[](#events)

You can modify the way this bundle works by listening events and modify some objects injected in the $event.

see the event documentation in Resources/doc/30-Events.md

Reference guide
===============

[](#reference-guide)

Add a field in the gridConfig
-----------------------------

[](#add-a-field-in-the-gridconfig)

when you add a field, you can set these parameters :

```
$gridConfig->addField('slug', array(
    'label' => 'Mon slug',
    'sortable' => false,
    'visible' => true,
    'filterable' => true,
    'translatable' => true,
    'formatValueCallback' => function($value) { return strtoupper($value); },
    'autoEscape' => true,
    'category' => null, // only used by you for checking this value in your events if you want to...
    'nullIfNotExists' => false, // for leftJoin, if value is not defined, this can return null instead of an exception
));
```

What can you personalize in your twig template
----------------------------------------------

[](#what-can-you-personalize-in-your-twig-template)

With the embed system of twig 1.8 and more, you can override some parts of the default rendering (see example in the "More advanced usage" paragraph).

You can consult the base twig template here to see what you can personalize.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 87.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~131 days

Total

34

Last Release

3166d ago

Major Versions

v1.11.0 → v2.0.02014-07-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2546b4ce718a257648634fe9c9902b022037a3f9568f3d48a72ae301d0145af?d=identicon)[lososoid](/maintainers/lososoid)

---

Top Contributors

[![philippe-levan](https://avatars.githubusercontent.com/u/393066?v=4)](https://github.com/philippe-levan "philippe-levan (131 commits)")[![b-b3rn4rd](https://avatars.githubusercontent.com/u/902016?v=4)](https://github.com/b-b3rn4rd "b-b3rn4rd (4 commits)")[![tyx](https://avatars.githubusercontent.com/u/245494?v=4)](https://github.com/tyx "tyx (4 commits)")[![lososoid](https://avatars.githubusercontent.com/u/31919703?v=4)](https://github.com/lososoid "lososoid (2 commits)")[![eliecharra](https://avatars.githubusercontent.com/u/6154987?v=4)](https://github.com/eliecharra "eliecharra (2 commits)")[![dfridrich](https://avatars.githubusercontent.com/u/3758421?v=4)](https://github.com/dfridrich "dfridrich (2 commits)")[![snovichkov](https://avatars.githubusercontent.com/u/1009975?v=4)](https://github.com/snovichkov "snovichkov (1 commits)")[![mfsirameshk](https://avatars.githubusercontent.com/u/5749709?v=4)](https://github.com/mfsirameshk "mfsirameshk (1 commits)")[![imishchenko](https://avatars.githubusercontent.com/u/3380470?v=4)](https://github.com/imishchenko "imishchenko (1 commits)")[![benjamindulau](https://avatars.githubusercontent.com/u/430689?v=4)](https://github.com/benjamindulau "benjamindulau (1 commits)")

---

Tags

paginatorfiltersortdatagrid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lososoid-data-grid-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/lososoid-data-grid-bundle/health.svg)](https://phpackages.com/packages/lososoid-data-grid-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[kitpages/data-grid-bundle

Symfony DataGridBundle

7780.9k1](/packages/kitpages-data-grid-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
