Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

107
Views
Yajra/JQuery datatable exporting child rows into CSV

I have a table with too much data. What I did was I added it as child rows to in order view. But when I want to export the contents of the table, the child rows are not included. Tried several solutions but none is working.

Here is my table

enter image description here

When I do export the data in the excel is only this one

enter image description here

I used the simple way of putting the buttons on the front end via

                dom: 'Bfrtip',
                buttons: [
                      {
                      extend: 'csv',
                      text: 'Export to CSV',
                      className: 'btn btn-default',
                      charset: 'utf-8',
                      fieldSeparator: ',',
                      bom: true,
                      filename: 'Corporates',
                      exportOptions: {
                          columns: ':not(.notexport)'
                      },}
                    ],

In my controller, I simply return datatables function of yajra.

    public function index(Request $request)
    {
        $corporate = Corporate::all();
        if($request->ajax()){
            return Datatables::of($corporate)
            ->addIndexColumn()
            ->addColumn('created_at', function ($row) {
                return Carbon::createFromFormat('Y-m-d H:i:s', $row->created_at)->format('M d, Y');
            })
            ->addColumn('buttons', function ($row) {
                return '<a href="'.route('admin.corporate.edit',$row->id).'" class="btn btn-primary"> Update</a> &nbsp; <button onclick="deleteCorporate('.$row->id.')" class="btn btn-danger">Delete</button>';
            })
            ->rawColumns(['buttons'])
            ->make(true);
        }
        return view('corporate.index');
    }

Does anyone know what I missed or what to do? Thanks in advance.

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.