定制 rollerworks/datagrid 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rollerworks/datagrid

最新稳定版本:v0.11.1

Composer 安装命令:

composer require rollerworks/datagrid

包简介

Datagrid system with a modular design and customizable

README 文档

README

RollerworksDatagrid provides a powerful datagrid system for your PHP applications.

Displaying an objects list is one of the most common tasks in web applications and probably the easiest one. So how can this library help you?

The Datagrid system makes the styling and transforming of your data more uniform and easier to use. Secondly the system can take care of specific (styling) issues like sorting and paginating. All without duplicating code or degrading performance.

Features

RollerworksDatagrid provides you with all features needed, including:

  • An Advanced column type system for uniform data transformation and styling in your datagrids.
  • Auto mapping of data to the datagrid.
  • Support for any data source (PHP array or any object implementing \Traversable).
  • (Optional, and coming soon) search/filter using RollerworksSearch.
  • (Optional, and coming soon) Integrated Paginating using Pagerfanta

Note: Passing a Pagerfanta object as data source does already work due to the IteratorAggregate implementation. The integration bridge however will make the rendering more uniform for datagrids.

Framework integration

RollerworksDatagrid can be used with any Framework of your choice, but for the best possible experience use the provided framework integration plug-ins.

  • Symfony Bundle
  • ZendFramework2 Plugin (coming soon)
  • Silex Plugin (coming soon)

Your favorite framework not listed? No problem, see the [Contributing Guidelines] on how you can help!

Installation and usage

Please ignore the instructions below if your use a framework integration. [Read the Documentation for master] for complete instructions and information.

Install the RollerworksDatagrid "core" library using [Composer]:

$ composer install rollerworks/datagrid

And create the DatagridFactory to get started:

use Rollerworks\Component\Datagrid\Datagrids;
use Rollerworks\Component\Datagrid\Extension\Core\Type as ColumnType;

$datagridFactory = Datagrids::createDatagridFactory();

$datagrid = $datagridFactory->createDatagridBuilder()
   ->add('id', ColumnType\NumberType::class)
   ->add('username', ColumnType\TextType::class)
   ->add('registered_on', ColumnType\DateTimeType::class)
   ->add('enabled', ColumnType\BooleanType::class, ['true_value' => 'Yes', 'false_value' => 'No'])
   ->getDatagrid('users_datagrid')
;

// Now set the data for the grid, this cannot be changed afterwards.
$datagrid->setData([
    ['id' => 1, 'username' => 'sstok', 'registered_on' => new \DateTime('2017-01-12 14:26:00 CET'), 'enabled' => true], 
    ['id' => 2, 'username' => 'doctorw', 'registered_on' => new \DateTime('1980-04-12 09:26:00 CET'), 'enabled' => false], 
    // etc...
]);

// Almost done, the datagrid needs to be rendered, see bellow.

Rendering

The core package however doesn't provide an implementation for this, you are free to use any compatible template engine you wish.

This example uses the TwigRendererEngine (which needs to be installed separately).

use Rollerworks\Component\Datagrid\Twig\Extension\DatagridExtension;
use Rollerworks\Component\Datagrid\Twig\Renderer\TwigRenderer;
use Rollerworks\Component\Datagrid\Twig\Renderer\TwigRendererEngine;

// Provide the path to the base theme.
$loader = new \Twig_Loader_Filesystem([...]);

$environment = new \Twig_Environment($loader);
$environment->addExtension(new DatagridExtension());
$environment->addRuntimeLoader(new \Twig_FactoryRuntimeLoader([TwigRenderer::class => function () uses ($environment) {
    // The second argument are filenames of datagrid themes.
    $rendererEngine = new TwigRendererEngine($environment, ['datagrid.html.twig']);
    
    return new TwigRenderer($rendererEngine);
}]));

$environment->render('my_page.html.twig', ['datagrid' => $datagrid->createView()]);

And in the my_page.html.twig twig Template simple use:

{{ rollerworks_datagrid(datagrid) }}

That's it! Your datagrid is now rendered, but not only that! Whenever you use an advanced technique like search you only need this much code in your template.

Resources

Who is behind RollerworksDatagrid?

RollerworksDatagrid is brought to you by Sebastiaan Stok.

License

RollerworksDatagrid is released under the MIT license.

The types and extensions are largely inspired on the Symfony Form Component, and contain a big amount of code from the Symfony project.

Support

[Join the chat] or use the issue tracker if your question is to complex for quick support.

Note: RollerworksDatagrid doesn't have a support forum at the moment, if you know a good free service let us know by opening an issue 👍

Contributing

This is an open source project. If you'd like to contribute, please read the [Contributing Guidelines]. If you're submitting a pull request, please follow the guidelines in the [Submitting a Patch] section.

Join the chat at https://gitter.im/rollerworks/datagrid [Composer]: https://getcomposer.org/doc/00-intro.md [Contributing Guidelines]: https://github.com/rollerworks/contributing [Submitting a Patch]: https://contributing.readthedocs.org/en/latest/code/patches.html [Read the Documentation for master]: http://rollerworksdatagrid.readthedocs.org/en/latest/ [Join the chat]: https://gitter.im/rollerworks/datagrid

rollerworks/datagrid 适用场景与选型建议

rollerworks/datagrid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.61k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2015 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ui」 「datagrid」 「component」 「rollerworks」 「table」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rollerworks/datagrid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rollerworks/datagrid 我们能提供哪些服务?
定制开发 / 二次开发

基于 rollerworks/datagrid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 23
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-15