Open xJuvi opened 1 year ago
+1
Below another use case in ->edit()
method. I would like to return an array
instead of returning only string
.
return (new Datatables())
->query($query)
->edit('raw_name', function ($col) {
$picture = (new Picture())
->setModuleType($col['module_type'])
->setRawName($col['raw_name'])
->setExtension($col['extension'])
->setConverted($col['converted'])
->setCreatedAt($col['created_at']);
return [
'large' => $picture->getUrl(),
'small' => $picture->getUrl('small'),
];
})
->generate()
->toJson();
...
{
data: "raw_name",
className: "text-center",
defaultContent: "",
orderable: false,
searchable: false,
render: (value, type, row) => {
return `<a class="item" href="${value['large']}">
<img src="${value['small']}" alt="${row['title']}" height="48" class="border">
</a>`
},
},
...
I suggest to remove a string
return type from Ozdemir\Datatables\Column->value()
method or change it to mixed
.
Thanks in advance.
In some cases it's useful to define a single dataset as array, f.e. if you want to order by an id bis display a human readeble name.
One example which i tried with server-side rendering is here: https://datatables.net/manual/data/orthogonal-data#Predefined-values
Is it possible to change it' I first look into the source code i think there are much changes required. If i try to define data as array i get an exception: