ilbronza/datatables

:package_description

v0.4 2020-10-22 08:11 UTC

This package is auto-updated.

Last update: 2025-08-21 21:08:46 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require ilbronza/datatables

add this lines to package.json dependencies list

"datatables.net-autofill-dt": "^2.3.6",
"datatables.net-buttons-dt": "^1.7.0",
"datatables.net-colreorder-dt": "^1.5.3",
"datatables.net-dt": "^1.10.24",
"datatables.net-fixedcolumns-dt": "^3.3.2",
"datatables.net-fixedheader-dt": "^3.1.8",
"datatables.net-keytable-dt": "^2.6.1",
"datatables.net-responsive-dt": "^2.2.7",
"datatables.net-rowgroup-dt": "^1.1.2",
"datatables.net-rowreorder-dt": "^1.2.7",
"datatables.net-scroller-dt": "^2.0.3",
"datatables.net-searchbuilder-dt": "^1.0.1",
"datatables.net-searchpanes-dt": "^1.2.2",
"datatables.net-select-dt": "^1.3.3",
"jszip": "^3.6.0",
"moment": "^2.29.1",
"webpack-jquery-ui": "^2.0.1"

run npm install from terminal

npm install

add these line to resources/js/app.js to include the required modules

require('./ilBronza.datatables.js');

keep in mind that it needs jQuery and jquery-ui, if you didn't required yet add to yout resources/js/app.js file

import $ from 'jquery';
window.$ = window.jQuery = $;

require('webpack-jquery-ui');

publish the package assets

php artisan vendor:publish --force --tag "datatables.assets"

compile the file with laravel-mix

npm run development

Usage

Form in table header and submit cell

You can populate a form in the header of the table and use a table cell as the submit button.
This feature is useful for quick inline filters or actions. To enable it, use the DatatableFieldSubmit field type in your configuration.

create a submit field

class DatatableFieldAddUnitloads extends DatatableFieldSubmit
{
    public $function = 'getAddUnitloadsToDeliveryUrl';
}

add the field to the table header

public function addPostFieldsToTable()
{
	$unitloads = Unitload::gpc()::whereIn('id', request()->unitloads)->get();

	foreach($unitloads as $unitload)
		$this->getTable()->addPostField(
			FormField::createFromArray([
				'label' => $unitload->getName() . ' (' . $unitload->getQuantity() . ')',
				'type' => 'text',
				'disabled' => true,
				'name' => 'unitloads[]',
				'value' => $unitload->getKey(),
			])
		);
}

use the created field in fields configuration

static function getFieldsGroup() : array
{
    return 
    [
        'fields' => 
        [
            'mySelfAddToDelivery' => 'warehouse::deliveries.addUnitloads'
        ]
    ];
}

Add data to headerData

Example for add data to th

'name' => [
    'type' => 'flat',
    'headerData' => [
        'reloadTable' => true,
        'merryChristmas' => 'something'
    ]
]

Example for fetcher field

    'mySelfTimingMessage.quantityWorkstations' => [
        'type' => 'iterators.each',
        'childParameters' => [
            'requiresPlaceholderElement' => true,
            'textParameter' => 'workstation_alias',
            'type' => 'links.fetcher',

            'fetcher' => [
                'urlMethod' => 'getPriceCalculationMessageUrl',
                //target is the place where to take the id from => 'currentField' || 'row'
                'target' => 'currentField',
                'target' => 'row'
            ]
        ],
        'width' => '25px'
    ],

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.