Skip to content
HTML Table Controller (add/remove/sort/search rows)
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
samples
src
README.md
bower.json
package.json

README.md

Table.js

HTML Table Controller (add/remove/sort/search rows)

Demo

Download

install via bower install table.js or npm install table.js

API Quick Start

Table constructor

  var myTable = new Table({
    'id': 'myTable', // id of table element
    'class': 'table', // classes of element
    'columns': ['Column1', 'Column2', 'Column3'], // name of columns
    'data': [
      ['value1', 'value2', 'value3'], // values of first row
      ['value1', 'value2', 'value3'] // values of second row
    ]
  });

.addRow(rowData, prepend)

  myTable.addRow(['value1', 'value2', 'value3'], false); // append: add a new row at final of table
  myTable.addRow(['value1', 'value2', 'value3', true); // prepend: add a new row at first position

.addRowAtIndex(rowData, index)

  myTable.addRow(['value1', 'value2', 'value3'], index); // add a new row at determined index

.removeRow(element)

  myTable.removeRow(trElement); // remove determined element (row/tr)

.removeRowByIndex(index)

  myTable.removeRowByIndex(index); // remove element (row/tr) at index position

.sort(columnIndex, sortDescending)

  myTable.sort(0, true); // sort in descending order by values at first column

.search(searchKey, columnIndex)

  myTable.search('value', 0); // search for 'value' in elements at first column

.reset()

  myTable.reset(); // return table cells to initial order

.clear()

  myTable.clear(); // remove all rows of table

.clone()

  var myTableCopy = myTable.clone();

LICENSE

MIT Licensed: http://mit-license.org/luizbills/

Something went wrong with that request. Please try again.