Skip to content
Max Ivak edited this page Jul 1, 2015 · 3 revisions

use view helpers to make columns of in table header sortable.

Example

View:

%table.table.table-striped.table-bordered
  %tr
    %th
      = link_to_sortable_column :title, 'Title'
    %th
      = link_to_sortable_column :category_id, 'Category'

View helpers

link_to_sortable_column

link_to_sortable_column(field_name, title, html_options)

options:

  • show_arrows Show arrows (asc/desc) when data is sorted by this column.
= link_to_sortable_column :category_id, 'Category', {:show_arrows=>true}

if no value is specified for the option, it will be set from global option:

# in initializer
SimpleSearchFilter.sortable_column_show_arrows = true

By default, it will show arrows.