evence/grid-bundle
Composer 安装命令:
composer require evence/grid-bundle
包简介
Provides an easy grid generator
README 文档
README
Easy method to generate a grid.
Installation
-
Add the bundle to your composer:
$ composer require evence/grid-bundle:dev-master
-
Add the bundle to your AppKernel.php:
new Evence\Bundle\GridBundle\EvenceGridBundle()
Grid withoud class
Add the following code to your controller:
$gridHelper = $this->get('evence.grid');
$grid = $gridHelper->createGridBuilder('EvenceOptinBundle:Supplier')
->addDataField('name', 'Name')
-> addAction('edit', 'Edit supplier', 'evence_optin_supplier_edit', array(), array('ROLE_ADMIN'), array('icon' => 'pencil'))
->setMappedParameters(array('id'));
return $gridHelper->gridResponse('EvenceCoreBundle:Admin:simple_grid.html.twig', array(
'grid' => $grid->createView()));
Grid within a class
namespace Acme\Bundle\DemoBundle\Grid; use Evence\Bundle\GridBundle\Grid\Grid; use Evence\Bundle\GridBundle\Grid\GridFieldConfigurator; use Evence\Bundle\GridBundle\Grid\GridActionConfigurator; use Evence\Bundle\GridBundle\Grid\GridFilterConfigurator; use Evence\Bundle\GridBundle\Grid\Filter\FilterMapper; class UserGrid extends Grid { public function getEntityName() { return 'EvenceCoreBundle:AdminUser'; } public function getOptions(){ return array('numbers' => false, 'checkbox' => false); } public function configureFields(GridFieldConfigurator $FieldConfigurator){ $FieldConfigurator ->addDataField('firstname', 'Firstname') ->addDataField('lastname', 'Lastname') ->addDataField('username', 'Username') ->addCustomField('fullname', 'Volledige naam', 'text', function($source, $field){ return $source->getFirstname(). ' ' . $source->getLastname(); }) ->addDataField('roles', 'Rollen', 'choice', array('choices' => AdminUser::getRoleTypes(), 'mapped' => false)); } public function getDataSourceType(){ return parent::DATA_SOURCE_ENTITY; } public function configureActions(GridActionConfigurator $actionConfigurator){ $actionConfigurator ->addAction('edit', 'Edit', 'admin_user_edit', array(),array('ROLE_ADMIN'), array('icon' => 'pencil', 'iconType' => 'fontawesome')) ->addAction('remove', 'Delete', 'admin_user_delete', array(),array('ROLE_ADMIN'), array('icon' => 'times', 'iconType' => 'fontawesome')); $actionConfigurator->setMappedParameters(array('id')); } /* * (non-PHPdoc) * @see \Evence\Bundle\GridBundle\Grid\Grid::configureFilter() */ public function configureFilter(GridFilterConfigurator $filterConfigurator) { $filterConfigurator->add('status', 'choice', [ 'choices' => Transaction::getStatusses() ]) ->add('dateFrom', 'datetime', []) ->add('dateTill', 'datetime', []); $fm = $filterConfigurator->getFilterMapper(); $fm->add(FilterMapper::gt('transactionAt', 'dateFrom'))->add(FilterMapper::lt('transactionAt', 'dateTill')); } }
Add the following code to your controller action:
$gridHelper = $this->get('evence.grid'); $grid = $gridHelper->createGrid(new UserGrid()); return $gridHelper->gridResponse('EvenceCoreBundle:Admin:user_read.html.twig', array('grid' => $grid->createView()));
Show grid in twig
Add the following code to your twig file:
{{ evenceGrid(grid, {'formAttributes': {'class': 'form'}}) }}
evence/grid-bundle 适用场景与选型建议
evence/grid-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 671 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「builder」 「grid」 「table」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 evence/grid-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 evence/grid-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 evence/grid-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
Plug-ins for DataTables
A component that allows creating responsive HTML tables or lists from data object
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
A Sphinx Query Builder extension for the Laravel Database package
Anax Database Active Record module for model classes.
统计信息
- 总下载量: 671
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-30