Sort data in Browser: Table Sorter and JCI-Plugin

  • Your task:
    Display JSON-data in the browser in a table which is sortable by the user.
  • Solution:
    Install JCI-Plugin and the plugin “Table Sorter
  • Example-Code:
    [jsoncontentimporterpro url=https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json method=rawget parser=twig] {{description}} <table id=”myTable” class=”tablesorter”>
    <thead><tr>
    <th>no (sortable)</th>
    <th class=”sortless”>x</th>
    <th>x (sortable)</th>
    <th>y (sortable)</th>
    <th>randomno (sortable) </tr></thead>
    <tbody>
    {%for v in values %}
    {% if loop.index<10 %}
    <tr><td>{{loop.index}}</td><td>{{v.x}}</td><td>{{v.x}}</td><td>{{v.y}}</td><td>
    {{ random(5000) }} </td></tr>
    {% endif %}
    {% endfor %}
    </tbody></table>
    [/jsoncontentimporterpro]
In action:
The number of Bitcoin transactions added to the mempool per second.
no (sortable) x x (sortable) y (sortable) randomno (sortable)
1154178214015417821403.532361111111681
2154178418015417841803.594409722223904
3154178622015417862203.63381944444515
4154178826015417882603.69406252088
5154179030015417903003.7481253611
6154179234015417923403.785347222224880
7154179438015417943803.7956253929
8154179642015417964203.774479166672301
9154179846015417984603.628923611112875

Credits: Thank you Lawrence from South Melbourne, Australia