symon-white/grid-bundle-s3
Composer 安装命令:
composer require symon-white/grid-bundle-s3
包简介
Ajax grid for Symfony3
README 文档
README
Ajax grid for Symfony3
Example
Using Twitter Bootstrap, jQuery Bootstrap Datepicker and fake data with Faker.
Requirements
- Twitter Bootstrap (not mandatory)
- If you choose to don't use Twitter Bootstrap, it'll be necessary to create your own style.
- jQuery Bootstrap Datepicker (not mandatory)
- If you choose to don't use Bootstrap Datepicker, please disable the datepicker as default in the configuration, "use_datepicker".
Installation
-
Add as a dependency in your composer file
"require": { "pedro-teixeira/grid-bundle":"dev-master" }
-
Add to your Kernel
// application/ApplicationKernel.php public function registerBundles() { $bundles = array( new PedroTeixeira\Bundle\GridBundle\PedroTeixeiraGridBundle() ); }
-
Add to your assetics configuration
# application/config/config.yml assetic: bundles: [ PedroTeixeiraGridBundle ]
-
Add assets to your layout
{% stylesheets '@PedroTeixeiraGridBundle/Resources/public/css/grid.css' %} <link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" /> {% endstylesheets %}{% javascripts '@PedroTeixeiraGridBundle/Resources/public/js/grid.js' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %} -
(optional) Adjust configurations
# application/config/config.yml pedro_teixeira_grid: defaults: date: use_datepicker: true date_format: 'dd/MM/yy' date_time_format: 'dd/MM/yy HH:mm:ss' pagination: limit: 20 export: enabled: true path: '/tmp/'
The configuration "use_datepicker" will set the input type as "text" and attach a jQuery plugin "datepicker()" to the filter.
Create your grid
-
Create the grid class
In your bundle, create a folder named "Grid" (or wathever namespace you want) and create your grid definition class.
<?php namespace PedroTeixeira\Bundle\TestBundle\Grid; use PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract; /** * Test Grid */ class TestGrid extends GridAbstract { /** * {@inheritdoc} */ public function setupGrid() { $this->addColumn('Hidden Field') ->setField('hidden') ->setIndex('r.hidden') ->setExportOnly(true); $this->addColumn('ID') ->setField('id') ->setIndex('r.id') ->getFilter() ->getOperator() ->setComparisonType('equal'); $this->addColumn('Created At') ->setField('createdAt') ->setIndex('r.createdAt') ->setFilterType('date_range') ->setRenderType('date'); $this->addColumn('Name') ->setField('name') ->setIndex('r.name'); $this->addColumn('Number') ->setField('number') ->setIndex('r.number') ->setFilterType('number_range'); $this->addColumn('Options') ->setField('option') ->setIndex('r.options') ->setFilterType('select') ->getFilter() ->setOptions(array( 'key' => 'value' )); $this->addColumn('Action') ->setTwig('PedroTeixeiraTestBundle:Test:gridAction.html.twig') ->setFilterType(false); } }
-
Use the grid factory in your controller
<?php namespace PedroTeixeira\Bundle\TestBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use JMS\SecurityExtraBundle\Annotation\Secure; /** * Default controller */ class DefaultController extends Controller { /** * @Route("/", name="test") * @Template() * * @return array */ public function indexAction(Request $request) { /** @var \Doctrine\ORM\EntityRepository $repository */ $repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity'); $queryBuilder = $repository->createQueryBuilder('r'); /** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */ $grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid', $request); $grid->setQueryBuilder($queryBuilder); if ($grid->isResponseAnswer()) { return $grid->render(); } return array( 'grid' => $grid->render() ); } }
-
Render in your template
{{ pedroteixeira_grid(grid) }}Or if you want to render the grid's html and the grid's js separately:
{{ pedroteixeira_grid_html(grid) }} ... {{ pedroteixeira_grid_js(grid) }}
Understanding
Continuous integration
To execute locally the checks that are executed on Travis:
composer install find ./Grid ./DependencyInjection ./Twig -name "*.php" -exec php -l {} \; ./bin/phpcs --extensions=php --standard=PSR2 ./Grid ./DependencyInjection ./Twig
symon-white/grid-bundle-s3 适用场景与选型建议
symon-white/grid-bundle-s3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「datagrid」 「grid」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 symon-white/grid-bundle-s3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 symon-white/grid-bundle-s3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 symon-white/grid-bundle-s3 相关的其它包
同方向 / 同关键字的高下载量 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.
FSi DataIndexer Component - Component created to provide one simple object indexing strategy for FSi DataSource and DataGrid components.
FSi DataGrid Component
Plug-ins for DataTables
Symfony DataGridBundle
TYPO3 extension providing content elements powered by gridelements and bootstrap. Available elements: container, columns, tabs, accordion, tile unit and card.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-06
