Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion about DataTablesHelper.php and add block name to table function #84

Open
wash34000 opened this issue May 31, 2021 · 1 comment

Comments

@wash34000
Copy link

Hello,

Do you thinks that it will possible to add a params to table function (file DataTablesHelper.php) to select the block name where the code will be appear in the layout ?

    public function table(string $id = 'datatable', array $dtOptions = [], array $htmlOptions = [], string $blocName = '') : string
    {
        $htmlOptions = array_merge($htmlOptions,  [
            'id' => $id,
            'class' => 'dataTable ' . ($htmlOptions['class'] ?? ''),
        ]);
        $table = $this->Html->tag('table', '', $htmlOptions);

        $code = $this->draw("#{$id}", $dtOptions);

        if ($blockName != '') {
           return $table.$this->Html->scriptBlock($code, ['block' => $blockName]);
        } else {
           return $table.$this->Html->scriptBlock($code);
        }
    }
@ypnos
Copy link

ypnos commented May 31, 2021

I'm not so sure if that's worth the convolution of the interface, you can simply call Html->tag() and DatatablesHelper->draw() directly instead of using DatatablesHelper->table(), which is purely a method for convenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants