lavdiu/php-grid
Composer 安装命令:
composer require lavdiu/php-grid
包简介
PHP Grid - Easily create flexible grids in PHP
README 文档
README
PHP Grid - simple php class that allows building dynamic grids using PHP and JS
Getting Started
Prerequisites
This class relies on the following libaries:
box/spoutandphpoffice/phpspreadsheetto generate Excel exports on the server side- SheetJS to generate Excel/CSV export in the browser.
- JQuery and
- Bootstrap 4
Installation
To install this library use
composer require lavdiu/php-grid
Copy grid.js from assets/ folder to your assets folder or root of your web directory and include it in your page.
Usage
require_once __DIR__ . '/../vendor/autoload.php'; use PhpGrid\PhpGrid; use PhpGrid\Column; use PhpGrid\ActionButton; $pdo = new PDO('mysql:host=localhost;dbname=database', 'username', 'password'); $grid = new PhpGrid($pdo, 'contacts_list'); $grid->setTitle('List of all contacts') ->setRowsPerPage(10) ->setSqlQuery("SELECT id, name, email, created_on FROM contact_list") ->addColumn(new Column('id', 'Contact Id', true, true, '?mod=contact&id={id}', '_blank')) ->addColumn(new Column('email', 'Email Address')) ->addActionButton(new ActionButton('View', '?mod=contact&id={id}', 'fa fa-eye')) ->addActionButton(new ActionButton('Update', '?mod=contact&id={id}&action=update', 'fa fa-pencil')); /** * Setting custom attributes to the button */ $deleteButton = new ActionButton('Delete', '?mod=contact&id={id}&action=delete', 'fa fa-trash'); $deleteButton->addAttribute('onclick', "return confirm('Are you sure?');"); $grid->addActionButton($deleteButton); /** * Set custom style/classes to the cell itself */ $col1 = new Column('name', 'Full Name'); $col1->setOuterElementCssClass('text-center'); $col1->setOuterElementCssStyle('background-color:silver'); $grid->addColumn($col1); /** * Set custom style/classes to the content of the cell */ $col2 = new Column('created_on', 'Registration Date', true); $col2->setInnerElementCssClass('border border-danger'); $col2->setInnerElementCssStyle('color:red;cursor:pointer;'); $grid->addColumn($col2); $grid->setDebug(true); #output additional debugging info in json responses if ($grid->isReadyToHandleRequests()) { $grid->bootstrap(); } echo $grid->draw();
See examples directory for more examples
sponsored by https://routerarena.com and https://ev-daily.com
lavdiu/php-grid 适用场景与选型建议
lavdiu/php-grid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lavdiu/php-grid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lavdiu/php-grid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 60
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-17