sebastienheyd/boilerplate

[Datatables] Hide columns based on ajax propery

thracefields opened this issue · 0 comments

Hello. Let's say for example that i have a file InvoicesDatatables.php
`<?php

namespace App\Datatables;

use App\Models\Company;
use App\Models\Currency;
use App\Models\Invoice;
use App\Models\Country;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Sebastienheyd\Boilerplate\Datatables\Button;
use Sebastienheyd\Boilerplate\Datatables\Column;
use Sebastienheyd\Boilerplate\Datatables\Datatable;

class InvoicesDatatable extends Datatable
{
public $slug = 'invoices';

public function datasource()
{
 //
}

public function setUp()
{
 //
}

public function columns(): array
{
    $columns = [];

  $column[] = Column::add('id')...

  if(request()->post('showMine'))
      $column[] = Column::add('name')...
   }
    return $columns;
}

}`

I'm trying to hide a column based on ajax property but it doesn't work. I recieve error 'column x not found'.
How can I solve that?