<commit_before># TableSortable

[![Build Status](https://travis-ci.org/odedd/table_sortable.svg?branch=master)](https://travis-ci.org/odedd/table_sortable)

TableSortable is a Rails complementation of The **tableSorter jQuery plugin**.

The tableSorter jQuery plugin is an excellent tool for filtering and sorting tables. 
When dealing with lots of rows, we usually want to split the table into multiple pages. tableSorter has a nifty [widget](https://mottie.github.io/tablesorter/docs/example-pager-ajax.html) for that, which requires using [mottie's fork](https://mottie.github.io/tablesorter/docs/index.html) of tableSorter.

Usually this is a scenario where we don't want to send our entire set of records to the front end,
which consequently means that the front end no longer knows the entire set of records to filter and sort through.
This requires our *server* to handle all that stuff, plus the pagination of the results. 

#### That's where TableSortable comes in!

TableSortable will handle all the backend filtering, sorting and pagination for you.

NOTICE: This gem is in very early stages of development, and is not yet fully documented.  Any input will be more than welcome.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'table_sortable'
```

Then run `bundle install` and you're ready to start

You should also probably be using jquery-tablesorter.  
For information regarding integration or tableSorter into your Rails project, 
please see the [jQuery tablesorter plugin for Rails](https://github.com/themilkman/jquery-tablesorter-rails) page.

## Usage

First, we need to setup our controller.  
Let's say we have our users controller. Let's include TableSortable so that we can use its methods.

```ruby
#controllers/users_controller.rb
class UsersController < ApplicationController
  include TableSortable<commit_msg>Make it clearer, thanks to comments by shibelkm<commit_after># TableSortable

[![Build Status](https://travis-ci.org/odedd/table_sortable.svg?branch=master)](https://travis-ci.org/odedd/table_sortable)

TableSortable adds multi-column, **server-side** filtering, sorting and pagination 
to the **tableSorter jQuery plugin**, so you don't have to worry about interpreting the query parameters,
customizing queries, fields to sort by, or how to send the correct page to the client.

It is a Rails backend complementation to the frontend tableSorter.js.


#### The Problem
The jQuery tableSorter plugin is an excellent tool for filtering and sorting tables. 
When dealing with lots of rows, we usually want to split the table into multiple pages. tableSorter has a nifty [widget](https://mottie.github.io/tablesorter/docs/example-pager-ajax.html) for that, which requires using [mottie's fork](https://mottie.github.io/tablesorter/docs/index.html) of tableSorter.

Usually this is a scenario where we don't want to send our entire set of records to the frontend,
which consequently means that the frontend no longer knows the entire set of records to filter and sort through.
This requires our *server* to handle all that stuff, as well as the pagination of the results.

#### The Solution: TableSortable
TableSortable will handle all the backend filtering, sorting and pagination for you.

NOTICE: This gem is in very early stages of development, and is not yet fully documented.  Any input will be more than welcome.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'table_sortable'
```

Then run `bundle install` and you're ready to start

You should also probably be using jquery-tablesorter.  
For information regarding integration or tableSorter into your Rails project, 
please see the [jQuery tablesorter plugin for Rails](https://github.com/themilkman/jquery-tablesorter-rails) page.

## Usage

First, we need to setup our controller.  
Let's say we have our users controller. Let's include TableSortable so that we can use its methods.

```ruby
#controllers/users_controller.rb
class UsersController < ApplicationController
  include TableSortable
{'fraction_non_alphanumeric': 0.070899209486166, 'fraction_numerical': 0.0, 'mean_word_length': 4.936950146627566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1232347', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1062, 'n_words': 506}