Silverstripe Version: 4.10
Question: Trying to sort by table headers in the CMS gridfield created by the Lumberjack module
I’m overwriting getLumberjackGridFieldConfig() and have successfully added columns to the display of this gridfield in the CMS. I now want to be able to sort clicking any of the gridfield’s headers (esp. Date). I can’t get this to work, the columns remain unsortable with the exception of the Title.
// Include any relevant code. If you have a lot of code, link to a gist instead.
private static $extensions = [
Lumberjack::class,
];
public function getLumberjackTitle()
{
return 'Title of subpages';
}
public function getLumberjackGridFieldConfig()
{
$config = GridFieldConfig_Lumberjack::create();
$dataColumns = $config->getComponentByType(GridFieldDataColumns::class);
$dataColumns->setDisplayFields([
'Title' => 'Title',
'Date.Nice'=> 'Date',
'LastEdited' => 'Changed'
]);
$sortableHeader = $config->getComponentByType(GridFieldSortableHeader::class);
$sortableHeader->setFieldSorting([
'Title' => 'Title',
'Date.Nice'=> 'Date',
'LastEdited' => 'Changed'
]);
return $config;
}