jfsimon / datagrid
There is no license information available for the latest version (dev-master) of this package.
A PHP datagrid component
dev-master
2013-07-04 16:12 UTC
Requires
- symfony/options-resolver: >=2.1
- symfony/property-access: >=2.2
Requires (Dev)
- symfony/config: >=2.1
- symfony/finder: >=2.1
- symfony/routing: >=2.1
- symfony/translation: >=2.1
- symfony/twig-bridge: >=2.1
- symfony/yaml: >=2.1
- twig/twig: >=1
This package is not auto-updated.
Last update: 2024-12-16 12:32:25 UTC
README
The main goal of this component is to render a result set from any data source as an HTML table with sorting and filtering capabilities (ideal for backends). This component aims to be framework-agnostic and provide bindings for most used PHP frameworks.
To see the component in action, you can check accptance tests:
Create CRUD actions:
$actions = Actions::enable() ->addGlobalRoute('create', 'beatle_create') ->addEntityRoute('read', 'beatle_read', array('beatle' => 'slug')) ->addEntityRoute('update', 'beatle_update', array('beatle' => 'slug')) ->addEntityRoute('delete', 'beatle_delete', array('beatle' => 'slug')) ;
1 - Usage with custom data:
$beatles = array( array('slug' => 'john', 'name' => 'John Lenon', 'birthday' => new \DateTime('1940-10-09'), 'alive' => false), array('slug' => 'paul', 'name' => 'Paul McCartney', 'birthday' => new \DateTime('1942-06-18'), 'alive' => true), array('slug' => 'georges', 'name' => 'Georges Harrison', 'birthday' => new \DateTime('1943-02-25'), 'alive' => false), array('slug' => 'ringo', 'name' => 'Ringo Starr', 'birthday' => new \DateTime('1940-07-07'), 'alive' => true), ); $schema = Schema::create() ->add('name', 'string', array('label' => 'Member name') ->add('birthday', 'datetime', array('time_format' => \IntlDateFormatter::NONE)) ->add('alive', 'boolean', array('label' => 'Still alive?', 'false_value' => 'no more :(')) ; $factory = new Factory(); $grid = $factory->createGrid(new Collection($beatles), array('schema' => $schema, 'actions' => $actions)); echo $this->getTwig()->render('{{ datagrid(grid) }}', array('grid' => $grid));
2 - Usage with Doctrine:
$factory = new DoctrineFactory($em); echo $factory ->createGrid(new Collection($em->findAll('Beatle')), array('actions' => $actions)) ->render(new TwigRenderer($twig, 'beatles.html.twig'));
Both will render: