Skip to content

Setting Up responseCallback. #2777

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

Closed
Nuhel opened this issue Apr 27, 2022 · 1 comment
Closed

Setting Up responseCallback. #2777

Nuhel opened this issue Apr 27, 2022 · 1 comment

Comments

@Nuhel
Copy link

Nuhel commented Apr 27, 2022

How to set responseCallback in datatable class . I saw there is a function named 'response' to set this, but i am confused from where to call this. So I override render function and called inside it. My code is attached below

public function render($view, $data = [], $mergeData = [])
    {
        $this->response(function($data){
            return ($this->makeResponse($data->toArray()));
        });
        return parent::render($view,$data,$mergeData);
    }

System details

  • Operating System: MacOs
  • PHP Version: 8.0..12
  • Laravel Version 8.75
  • "yajra/laravel-datatables": "^1.5",
    "yajra/laravel-datatables-buttons": "^4.0",
    "yajra/laravel-datatables-editor": "^1.0",
    "yajra/laravel-datatables-oracle": "^9.19"
yajra added a commit to yajra/laravel-datatables-buttons that referenced this issue May 10, 2022
@yajra
Copy link
Owner

yajra commented May 10, 2022

Added a test for this feature via yajra/laravel-datatables-buttons@59e71d1.

        $router->get('/users/response', function (UsersDataTable $dataTable) {
            return $dataTable->response(function (Collection $data) {
                $data['recordsTotal'] = 2;
                $data['recordsFiltered'] = 1;

                return $data;
            })->render('tests::users');
        });

@yajra yajra closed this as completed May 10, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants