Easy KnockoutJS Pagination with Data Tables
October 2, 2014development
Data Tables makes it super easy to add pagination, searching, and sorting to tabular data bound with KnockoutJS
TL;DR: DataTables provides simple pagination, sorting, and searching capabilties to tabular data bound with KnockoutJS - DEMO
So I was working on a WordPress plugin that pulled data from a SQL Server database via ASP.Net Web API and was using KnockoutJS to make the binding super easy. This worked great and was surprisingly simple to accomplish. However some of the data that was coming back was over 1,000 rows. This obviously didn't look great to the users and was not really practical nor usable. So I started down the path of handling paging at the API level and passing the page as a parameter... Yada Yada Yada you've been there.
But then I found DataTables ... an excellent table plugin for jQuery.
Hey I need that! DataTables provides extremely simple pagination, searching, sorting and more functionality to any HTML table. So in order to get this to work you can use the declarative foreach feature of Knockout to build out your table with the JSON data coming back from your API. Enough of the boring stuff, here's the code..