Pager & DataGrid bundle for Symfony2
Main features are :
- HTTP or Console mode
- "Adapters" with the ability to sort and filter:
- Array
- Doctrine ORM QueryBuilder
- Doctrine MongoDB QueryBuilder
- "Handlers" for various javascript libraries
- jqGrid
- Flexigrid
- Dynatable
- DataTables
- jQuery Autocomplete
- Bootstrap Typeahead
- jQuery Bootgrid
- Themable:
- Bootstrap 2
- Bootstrap 3
- Foundation
MIT (see LICENSE file)
composer.phar require "datatheke/pager-bundle"
<?php
//...
$bundles = array(
//...
new Datatheke\Bundle\PagerBundle\DatathekePagerBundle(),
);
More exemples in the documentation
PHP
<?php
/**
* @Template()
*/
public function datagridAction()
{
$datagrid = $this->get('datatheke.datagrid')->createHttpDataGrid('MyBundle:MyEntity');
$view = $datagrid->handleRequest($this->getRequest());
return array('datagrid' => $view);
}
TWIG
{{ datagrid(datagrid) }}
{# OR BETTER #}
{% extends '::base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
{{ datagrid_stylesheets(datagrid) }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ datagrid_javascripts(datagrid) }}
{% endblock %}
{% block body %}
<div class="container">
<h1>Test DataGrid</h1>
{{ datagrid_content(datagrid) }}
</div>
{% endblock %}
PHP
<?php
/**
* @Template()
*/
public function pagerAction()
{
$pager = $this->get('datatheke.pager')->createHttpPager('MyBundle:MyEntity');
$view = $pager->handleRequest($this->getRequest());
return array('pager' => $view);
}
TWIG
{% extends '::base.html.twig' %}
{% import 'DatathekePagerBundle:Pager:bootstrap3.html.twig' as helper %}
{% block stylesheets %}
{{ parent() }}
{{ helper.stylesheets() }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ helper.javascripts() }}
{% endblock %}
{% block body %}
<div class="container">
<h1>Test pager</h1>
<form action="{{ pager_form_path(pager) }}" method="post">
<div class="panel panel-default">
<div class="panel-heading">
{{ helper.toolbar(pager) }}
</div>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>{{ helper.orderBy(pager, 'firstname', 'Firstname') }}</th>
<th>{{ helper.orderBy(pager, 'lastname', 'Lastname') }}</th>
</tr>
<tr>
<th>{{ helper.filter(pager, 'firstname') }}</th>
<th>{{ helper.filter(pager, 'lastname') }}</th>
</tr>
</thead>
<tbody>
{% for row in pager.items %}
<tr>
<td>{{ row.firstname }}</td>
<td>{{ row.lastname }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{{ helper.paginate(pager) }}
</form>
</div>
{% endblock %}