Community Documentation

Table sorting

Last updated November 23, 2012. Created by drupalshrek on November 23, 2012.
Log in to edit this page.

Table sorting

To produce a result table which can be sorted by any column, use the TableSort extender and then add the table header. Note that an extender does return a new query object that you need to use from that point on.

<?php
$query
= $query
 
->extend('TableSort')
  ->
orderByHeader($header);
?>

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Intermediate, Advanced
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here