fantomx1 / datatables
该包的最新版本(0.999)没有可用的许可信息。
正在开发中的包
0.999
2020-09-01 10:11 UTC
Requires
- components/jquery: ^3.5
- components/jqueryui: ^1.12
- fantomx1/iohandlers: 1.0
- fantomx1/lightweight-untypable-combobox: 1.0
- fantomx1/packages-assets-support: 999
- fantomx1/view-locator: @dev
- twbs/bootstrap: ^4.5
This package is auto-updated.
Last update: 2024-09-29 05:48:51 UTC
README
通用的框架无关的Composer可安装数据表格
通过以下命令安装此库后,安装库的资产(它使用fantomx1/packages-assets-support包进行操作):
安装此库的资产
执行以下命令
cd vendor/fantomx1/datatables && php ../../../vendor/fantomx1/packagesAssetsSupport/initAssets.php -w=../../../backend/web -o=assets
其中,-w选项代表documentRoot/webDir目录的相对路径,用于放置资产(注意:以后可以添加命令功能,交互式地询问documentRoot位置,以及连接到composer post-install)
示例
用法
(使用columnsDefinitions构建器)- 实际上没有别的了,表格完全功能,可排序、可筛选
$articleTableWidget = new DataTableWidget();
// will be needed also at column
$articleTableWidget->_assoc_ini->setIni(
$articleTableWidget->_assoc_ini::INI_QUERY_EXECUTOR,
YiiQueryExecutorPlugin::class
);
$articleTableWidget->init();
$articleTableWidget->setQuery("
SELECT
a.*
ac.title as category_id,
FROM article a
JOIN article_category ac ON a.category_id = ac.id
");
$articleTableWidget->setColumnsDefinition(
[
$articleTableWidget->column('category_id')
->setFilter()
->setTypeSelect()
->setDataQuery(
"article_category",
"id",
"title"
)->getFilter()
->setCaption('Category')
->setOrderable(),
$articleTableWidget->column('slug')
->setFilter()
->setTypeSelect()
->setData(
[
'1'=>'aaa',
'2'=>'bbb',
'3'=>'ccc'
]
)->getFilter()
//->setCaption('aaa')
->setOrderable(),
$articleTableWidget->column('id')
->setFilter()
->setTypeText()
// ->setData(
// [
// '1'=>'aaa',
// '2'=>'bbb',
// '3'=>'cccc'
// ])
->getFilter()
//->setCaption('bbb')
->setOrderable()
]
);
// perhaps passed to some view
$articleTableWidget->run();
路线图: https://trello.com/b/7wwQRgNq/fantomx1-datatablesbacklog