Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Latest commit

 

History

History
51 lines (30 loc) · 1.34 KB

README.rdoc

File metadata and controls

51 lines (30 loc) · 1.34 KB

UOrder

Current features

  • order by a single column/attribute

  • possibility to add your own callbacks on ordering

Dependencies

  • jruby-rails

  • jquery-ui-rails

Installation

  • Gemfile

    gem 'u_order', '~> 0.2', :git => 'https://github.com/m0gg/u_order-rails.git'
    
  • application.js

    //= require u_order

Usage

  • Identify a table to be ordered, data-table is an ordergroup name you may choose yourself, it’s independant of the actual table or collection.

    <table data-table="posts">
      <tr>
  • Ordermodes are controlled by the order-mode attribute. Default is +“single”+, +“multi”+ allows to order by more than one attribute, last clicked with highest priority. (since 0.3.a)

    <table order-mode="multi" data-table="posts">
  • Set the attribute to order with data-order, this one would order by title

    <th data-order="title">Title</th>
  • Ordercycles are controlled by the order-cycle attribute. Default is +“asc desc”+, there are 3 implemented cycles, asc, desc and none. If none is reached, the ordering on this head is removed.

    <th order-cycle="desc asc none" data-order="title">Title</th>
  • The last thing is to call the uorder method with chosen params on your ActiveRecord relation. The data-order attribute is prefixed with “uorder_”

    @posts = Post.uorder(params[:uorder_posts])