When creating a backend list view there are options to sort items by clicking on the column title Default Ordering Column
<th scope="col" style=".." class="text-center d-none d-md-table-cell">
<?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?></th>
When adding searchtools.sort to one of my columns like so:
<th scope="col" style="width: 1%" class="d-none d-md-table-cell text-center">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_COMPONENT_TABLE_TABLEHEAD_SHORTCODE_TITLE', 'a.shortcode', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?></th>
aswell as the respective content in the filters_view.xml:
...
<form>
...
<fields name="list">
<field name="fullordering" ...>
...
<option value="a.shortcode ASC">COM_COMPONENT_FILTER_SHORTCODE_ASC</option>
<option value="a.shortcode DESC">COM_COMPONENT_FILTER_SHORTCODE_DESC</option>
...
The list can be sorted but i have no visual indicator on the clicked column header. It just "stays" like its not sorted at all.
Even the examples I've found in the web has the same "issue" on the visible side. When using the title column in the same view it works for this column but not for "non-default" columns.
I've already seen that there is a method in the HTMLView called "getSortFields" but even when adding there my column in the array it doesn't change anything:
protected function getSortFields(): array
{
return [
'a.published' => Text::_('JSTATUS'),
'a.title' => Text::_('JGLOBAL_TITLE'),
'a.id' => Text::_('JGRID_HEADING_ID'),
'a.group_id' => Text::_('COM_COMPONENT_TABLE_TABLEHEAD_GROUPID_TITLE'),
];
}
What I am missing here?
HTMLHelper::_('searchtools.sort')
. It means$listOrder
/$listDirn
aren't populated correctly.