Closed renjithjr closed 6 years ago
Seems like you forgot to provide columns
option as explained in the tutorial.
No i have provided columns option as explained in the tutorial.
$columns = [
[
'field' => 'Customers.id',
'data' => 'id',
'searchable' => false,
],
[
'title' => ('Title'),
'field' => 'Customers.name',
'data' => 'name'
],
[
'title' => ('Actions'),
'field' => 'Customers.id',
'data' => 'id'
],
];
Please provide full code, this snippet does not show your call into DataTables helper.
### Controller
public function index()
{
$columns = [
[
'field' => 'Customers.id',
'data' => 'id',
'searchable' => false,
],
[
'title' => ('Title'),
'field' => 'Customers.name',
'data' => 'name'
],
[
'title' => ('Actions'),
'field' => 'Customers.id',
'data' => 'id'
],
];
$data = $this->DataTables->find('Customers', 'all', ['conditions'=>[], 'order'=>'Customers.id desc'], $columns);
$this->set('columns', $columns);
$this->set('data', $data);
$this->set('_serialize', array_merge($this->viewVars['_serialize'], ['data']));
}
Please format your code in a readable manner, to be honest I consider it quite rude to dump the code like this when you are asking for help.
Next time try ```php it is in the Github Markdown documentation.
There is some other problems in your code, but I really don't see how you could get to this error message with the code you posted.
Notice (8): Undefined index: columns [ROOT/vendor/ypnos-web/cakephp-datatables/src/View/Helper/DataTablesHelper.php, line 101]
Warning (2): Invalid argument supplied for foreach() [ROOT/vendor/ypnos-web/cakephp-datatables/src/View/Helper/DataTablesHelper.php, line 101]