prezent / grid
Generic data grids and lists
Installs: 19 129
Dependents: 1
Suggesters: 0
Security: 0
Stars: 13
Watchers: 10
Forks: 4
Open Issues: 0
Requires
- php: ^7.0|^8.0
- ext-intl: *
- symfony/options-resolver: ^4.0|^5.0|^6.0|^7.0
- symfony/property-access: ^4.0|^5.0|^6.0|^7.0
- twig/twig: ^2.0|^3.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- dev-master / 1.0.x-dev
- 0.14.1
- 0.14.0
- 0.13.0
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.x-dev
- 0.11.6
- 0.11.5
- 0.11.4
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.0
- 0.9.17
- 0.9.16
- 0.9.15
- 0.9.14
- 0.9.13
- 0.9.12
- 0.9.11
- 0.9.10
- 0.9.9
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-twig-update
This package is auto-updated.
Last update: 2024-11-28 12:51:01 UTC
README
A framework-independent library for building and rendering generic datagrids in PHP.
Installation
This extension can be installed using Composer. Tell composer to install the extension:
$ php composer.phar require prezent/grid
Symfony users should use the prezent/grid-bundle. This sets up everything automatically and adds extra features such as router and translation integration.
Quick example
If you have any experience using Symfony Forms, then this grid library will feel very familiar. Start by defining a grid:
<?php namespace My\Grids; use Prezent\Grid\BaseGridType; use Prezent\Grid\Extension\Core\Type\DateTimeType; use Prezent\Grid\Extension\Core\Type\StringType; use Prezent\Grid\GridBuilder; class MyGridType extends BaseGridType { public function buildGrid(GridBuilder $builder, array $options = []) { $builder ->addColumn('id', StringType::class, [ 'label' => 'ID', 'url' => '/view/{id}', ]) ->addColumn('name', StringType::class) ->addColumn('created', DateTimeType::class, ['pattern' => 'yyyy qqq']) ->addAction('edit', ['url' => '/edit/{id}']) ; } }
In your controller, create the grid and assign it to your view:
<?php namespace My\Controllers; use My\Grids\MyGridType; class MyController { public function indexAction() { $data = $this->db->findSomeData(); $grid = $this->getService('grid_factory')->createGrid(MyGridType::class); $this->view->data = $data; $this->view->grid = $grid->createView(); } }
Finally, render the grid using Twig:
{{ grid(grid, data) }}
Documentation
The complete documentation can be found in the doc directory.