fantomx1 / datatables
package under development
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/fantomx1/datatables
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: 2025-10-29 03:18:58 UTC
README
generic framework-agnostic composer installable data-tables
After installing this library via composer install fantomx1/datatables ,
install the library's assets as follows (it utilizes package fantomx1/packages-assets-support for the operation)
Installing this library's assets
execute this command
cd vendor/fantomx1/datatables && php ../../../vendor/fantomx1/packagesAssetsSupport/initAssets.php -w=../../../backend/web -o=assets
where the -w option stands for the relative path to the documentRoot/webDir directory, where to position the assets (Note: later can be added functionality of the command asking interactively for the documentRoot location, plus hooking up on composer post-install )
Example:
Usage:
(with columnsDefinitions builder) - really nothing else anymore, and the table is fully functional sortable, filterable
        $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();
Roadmap: https://trello.com/b/7wwQRgNq/fantomx1-datatablesbacklog
