mdzzohrabi / datagrid-bundle
Symfony 数据网格包
2.2.16
2015-05-10 10:49 UTC
Requires
- php: >=5.3.2
- symfony/symfony: >=2.0.0
- twig/twig: >=1.5.0
Suggests
- ext-intl: Translate the grid
- ext-mbstring: Convert your data with the right charset
- PHPExcel: Export the grid (Excel, HTML or PDF)
This package is not auto-updated.
Last update: 2024-09-20 21:01:58 UTC
README
受 Zfdatagrid 和 Magento Grid 启发的 Symfony2 数据网格
此包由 Stanislav Turza (Sorien) 创始。
特性
- 支持实体(ORM)、文档(ODM)和向量(数组)数据源
- 可排序和可过滤,具有操作符(比较操作符、范围、以...开始/结束、包含/不包含、是否定义、正则表达式)
- 自动类型化列(文本、数字、布尔值、数组、日期时间、日期...)
- 日期时间、日期和数字列(小数、货币、百分比、持续时间、科学、文字)的本地化支持
- 输入、选择、复选框和单选按钮过滤器,填充网格数据或值数组
- 导出(CSV、Excel、PDF、XML、JSON、HTML...)
- 批量操作
- 行操作
- 支持实体数据源中的映射字段
- 使用安全角色保护列、操作和导出
- 注解和 PHP 配置
- 外部过滤器框
- Ajax 加载
- 分页(您还可以使用 Pagerfanta)
- 列宽和列对齐
- 翻译标题前缀
- 同一页面上多网格的网格管理器
- ORM 和 ODM 数据源的分组配置
- 简单的模板覆盖(twig)
- 自定义列和过滤器创建
- ...
文档
参见 摘要。
屏幕截图
此 CSS 样式文件 中的完整示例
英文中的简单示例,带有外部过滤器框
法语中的相同示例
这些屏幕截图中使用的数据(这是一个 phpMyAdmin 屏幕截图)
简单的 ORM 数据源网格
<?php namespace MyProject\MyBundle\Controller; use APY\DataGridBundle\Grid\Source\Entity; class DefaultController extends Controller { public function myGridAction() { // Creates a simple grid based on your entity (ORM) $source = new Entity('MyProjectMyBundle:MyEntity'); // Get a Grid instance $grid = $this->get('grid'); // Attach the source to the grid $grid->setSource($source); // Return the response of the grid to the template return $grid->getGridResponse('MyProjectMyBundle::myGrid.html.twig'); } }
在实体中对网格进行简单配置
<?php namespace MyProject\MyBundle\Entity use Doctrine\ORM\Mapping as ORM; use APY\DataGridBundle\Grid\Mapping as GRID; /** * @GRID\Source(columns="id, my_datetime") */ class MyEntity { /* * @ORM\Column(type="integer") */ protected $id; /* * @ORM\Column(type="datetime") */ protected $my_datetime; }
在 twig 模板中显示网格
<?php <!-- MyProject\MyBundle\Resources\views\myGrid.html.twig --> {{ grid(grid) }}
并清除您的缓存。



