datatheke / pager-bundle
Symfony 的分页和数据网格组件包
v0.5.2
2016-03-06 15:12 UTC
Requires
- php: >=5.3.3
- symfony/config: ~2.3|~3.0
- symfony/console: ~2.3|~3.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/form: ~2.3|~3.0
- symfony/framework-bundle: ~2.3|~3.0
- symfony/http-foundation: ~2.3|~3.0
- symfony/http-kernel: ~2.3|~3.0
- symfony/options-resolver: ~2.3|~3.0
- symfony/property-access: ~2.3|~3.0
- symfony/routing: ~2.3|~3.0
Requires (Dev)
- ext-pdo_sqlite: *
- doctrine/orm: ~2.3
- jms/serializer: ~0.16
- pagerfanta/pagerfanta: ~1.0
- phpunit/phpunit: ^4.0
Suggests
- doctrine/doctrine-bundle: To use ORMQueryBuilderAdapter and ORMEntityAdapter
- doctrine/mongodb-odm-bundle: To use MongoDBQueryBuilderAdapter and MongoDBDocumentAdapter
- doctrine/orm: To use ORMQueryBuilderAdapter and ORMEntityAdapter
- jms/serializer-bundle: To serialize Pager and DataGrid
README
关于
Symfony2 的分页和数据网格组件包
主要功能包括
- HTTP 或控制台模式
- 具有排序和过滤功能的“适配器”
- 数组
- Doctrine ORM QueryBuilder
- Doctrine MongoDB QueryBuilder
- 各种 JavaScript 库的“处理器”
- jqGrid
- Flexigrid
- Dynatable
- DataTables
- jQuery Autocomplete
- Bootstrap Typeahead
- jQuery Bootgrid
- 主题化
- Bootstrap 2
- Bootstrap 3
- Foundation
许可证
MIT (见 LICENSE 文件)
安装
使用 composer 安装
composer.phar require "datatheke/pager-bundle"
更新您的 app/AppKernel.php
<?php //... $bundles = array( //... new Datatheke\Bundle\PagerBundle\DatathekePagerBundle(), );
用法
更多示例请参阅 文档
数据网格
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 %}