KivaSort is a simple JQuery plugin which uses the Kiva API to get information on all of the Kiva field partners, and then uses the DataTables JQuery Plugin to wrap the data in a dynamic sortable and filterable table.
For installation and usage instructions, see the README file. For source code, see the plugin's Github page.
This page provides several example tables using the JS Bin service so that you can play around with the HTML and JavaScript.
For a deployed example of KivaSort, see KivaSort.americancynic.net.
A basic six-column table:
This example demonstrates how to pass options to DataTables (in this case, 'pageLength', 'scrollX', and 'order'). The order attribute causes the table's default sort order to be Portfolio Yield and then Profitability in descending order. It also uses the DataTables API (the columns() and search() functions) to filter out rows which don't have any Portfolio Yield or Profitability data. The effect is a small table which makes it easy to find the field partners with the highest interest rates.
This example demonstrates how to use the columns
option to set arbitrary column titles:
This example uses the ks_partnerData
option to load local JSON (a portion of the data fetched from the Kiva API earlier) to populate the table. No AJAX call is made.
It also shows how to use the Datatables Buttons extension to display the two custom buttons provided by jquery-kivasort ("JSON" and "Reload").
The following columns are available or use in your KivaSort table: