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

按照quickstart完成后buttons不显示|After completing the quickstart, the buttons are not displayed #3202

Open
NEETLee opened this issue Dec 4, 2024 · 3 comments

Comments

@NEETLee
Copy link

NEETLee commented Dec 4, 2024

按照quickstart完成后buttons不显示

问题在于第三步03. Setup a Users DataTable

错误代码

app/DataTables/UsersDataTable.php


...
   public function html(): HtmlBuilder
    {
        return $this->builder()
                    ->setTableId('users-table')
                    ->columns($this->getColumns())
                    ->minifiedAjax()
                    ->orderBy(1)
                    ->selectStyleSingle()
                    ->buttons([
                        Button::make('add'),
                        Button::make('excel'),
                        Button::make('csv'),
                        Button::make('pdf'),
                        Button::make('print'),
                        Button::make('reset'),
                        Button::make('reload'),
                    ]);
    }
...

正确代码

...

    public function html(): HtmlBuilder
    {
        return $this->builder()
            ->setTableId('users-table')
            ->columns($this->getColumns())
            ->minifiedAjax()
            ->orderBy(1)
            ->selectStyleSingle()
            ->buttons([
                Button::make('add'),
                Button::make('excel'),
                Button::make('csv'),
                Button::make('pdf'),
                Button::make('print'),
                Button::make('reset'),
                Button::make('reload'),
            ])->layout(Layout::make(['topStart' => 'buttons']));
    }
...

System details

  • Win10|vagrant homestead
  • PHP8.3
  • Laravel 11
  • Laravel-Datatables v11
@NEETLee
Copy link
Author

NEETLee commented Dec 4, 2024

请修复文档,谢谢
经过3个小时时间排查问题,了解了整个插件运行机制之后才找到问题所在,留下记录给有需要的人参考

@Afumoons
Copy link

@NEETLee 我确实需要那份参考记录!

@yajra
Copy link
Owner

yajra commented Dec 13, 2024

Great observation! The documentation still refers to the DOM option. In DataTables v2, 'layout' replaces 'dom', which means buttons must be included in the layout.

->layout(Layout::make(['topStart' => 'buttons']))

Feel free to submit a PR in the docs by editing the page in Github. Thanks!

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

3 participants