Receive data in sight - Yajra DataTables

0

I need to send a data through the render() method, however I do not know how to receive it in the view. Here is my code ( print_r($datos) generates me error: Undefined variable: datos ):

Driver: InventoryDetailReportController.php

class InventoryDetailReportController extends Controller
{

    public function index (InventoryDetailDataTable $dataTable, Request $request, $inventario='') {

        $datos = array();
        array_push($datos, $inventario);
        return $dataTable->with('inventario', $inventario)->render('vista-reporte-inventario', $datos);

    }

}

View: vista-report-inventory.blade.php

@extends('layouts.master')

@section('content')

{!! $dataTable->table() !!}
{!! print_r($datos) !!}

@endsection

@push('scripts')
/** Aquí van los scripts de datatables */
{!! $dataTable->scripts() !!}
@endpush

I tried to access the data with $dataTable->datos but it did not work for me. I appreciate any help.

    
asked by Acentellao17 21.10.2017 в 01:00
source

1 answer

0

You have the addColumn and editColumn options that are likely to suit you for whatever you want.

For example

DataTables::of($datos)
    ->addColumn('acciones', function ($dato) {
            return '<div style="background-color: #fff;height: 20px;"></div>'; // Añade una nueva columna
        })->editColumn('color', function ($dato) { // Edita la columna con nombre color
            return '<div style="background-color: ' . $dato->color . ';height: 20px;"></div>';
        })->make(true);
    
answered by 24.10.2017 в 09:27