domingo, 24 de noviembre de 2013

SortTable - how to sort the rows of a table with jquery


SortTable Jquery

By http://jquery-manual.blogspot.com


Download on GITHUB

The sortTable function allow sort the rows of a table ASC or DESC through one column number, if not selected, The table is sorted from the first column.

The first parameter of the function accepts one of the following values:
  • number: Sort column form numbers.
  • letter: Sort column from letters, including Latin characters.
  • both: Sort column from letters and numbers.

The second parameter (optional) contains the following options:
  • reverse: false | true . Default false, indicates whether the order is ascending or descending.
  • column: int . Default 1(first column). The number of the column that will be responsible for sorting rows.

IDVALUE
99Ninety-nine
1200thousand two hundred
116hundred and sixteen
220two hundred and twenty
900nine hundred
23twenty-three
150hundred and fifty

$("#btn-1").click(function(){
$("#table1").sortTable("number", {column: 1, reverse: false});
});

idNameSurname
1PedroGarcía
2JoséRedondo
3AlbertoMárquez
4DiegoRodríguez
5JuanGuardado
6MiguelFenández
7AntonioGonzález
8ÁlvaroPuerta

$("#btn-2").click(function(){
$("#table2").sortTable("letter", {column: 2, reverse: false});
});

SRC
image-3.jpg
image-23.jpg
image-40.jpg
image-1.jpg
image-28.jpg
image-14.jpg
image-8.jpg
image-12.jpg

$("#btn-3").on("click", function(){
$("#table3").sortTable("both", {column: 1, reverse: false});
});




No hay comentarios: