Knockout DataTable is a flexible and reusable Knockout.js view model for data tables.
Check out the demo to get a quick idea of how it works and how to use it.
To install it in your bower-enabled project, run bower install knockout-datatable
.
Or drop the knockout-datatable{.min}.js
file in your vendor assets javascript folder and require it in your application.
Refer to the demo for detailed usage instructions.
The following methods are available on the DataTable instance:
prevPage()
- go to the previous page (if not on page 1)nextPage()
- go to next page (if not on last page)toggleSort(field)
- switches to ascending sort if sorted descending by
field
- switches to descending sort if sorted ascending by
field
- sorts ascending by
field
if not already sorted byfield
- switches to ascending sort if sorted descending by
gotoPage(pageNum)
- sets the current page topageNum
pageClass(pageNum)
- returns"active"
ifpageNum
is the current pageaddRecord(new_record)
- pushesnew_record
onto the datatable's rowsremoveRecord(record)
- removesrecord
from the datatable's rowsreplaceRows(new_rows_array)
- resets the datatable's rows to
new_rows_array
- sets the current page to
1
- resets the datatable's rows to
forceFilter(true|false)
- enable / disable forcing filtering of the roles- tells DataTable to filter the rows even if the current filter is falsey
To build the Knockout DataTable coffeescript source, do the following in a node.js enabled environment:
npm install -g grunt-cli
npm install
grunt
To run the tests, do the following in a node.js enabled environment:
npm install -g grunt-cli
npm install
grunt test
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
See Contributors
Knockout DataTable is released under the MIT License. Please see the LICENSE file for details.