This custom field for Kirby CMS displays Kirby's Structure Field as a DataTable inside the panel (Kirby's backend).
DataTables from DataTable.
CSS from Jon Gacnik.
fields:
...
datatable:
label: DataTable
type: datatable
fields:
text:
label: text
type: textarea
picture:
label: Background Image
type: image
headline:
label: Headline Text
type: text
A custom filter can be applied to the data before it is put out as a json response. This is perfect if you need to modify some of the data for presentation, change columns, etc.
Create a simple plugin site/plugins/mydatafilters/mydatafilters.php
:
<?php
class MyDataFilters {
static function myfilterfunc($data) {
// filter data here
foreach ($data as $entry) {
if ($data->{$entry->{'id'}}->{'text'} == '') {
$data->{$entry->{'id'}}->{'text'} = '- no text -';
}
}
return $data;
}
}
Update field definition:
datatable:
label: DataTable
type: datatable
filter: MyDataFilters::myfilterfunc
fields:
text:
label: text
type: textarea
...
You use it similar to Kirby's Structure Field.
git clone https://github.com/fendinger/kirby-datatable.git site/fields/datatable
From the root of your kirby install.
Alternatively you can download the zip file, unzip it's contents into site/fields/datatable.
Some issues related to the structure field of Kirby Panel do also affect the datatable field.
Not all DataTables functions are implemented already. But it's a good starting point.