I try to add the possibility to order by column in the header of my table element.
I started to use Drupal 8 and I can't find any clear documentation about table on the API site to do what i want...
Thanks in advance.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
You have to do this while defining the header array like
$header = array( array( 'data' => t('Url'), 'field' => 'd.path', 'sort' => 'asc', ), array( 'data' => t('Text'), 'field' => 'd.text', ), );
So, this table will have two columns, Url & Text. And it will be sorted in ascending order by column Url.