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)
1155326962015532696203.906944444444627
2155327166015532716603.985868055564434
3155327370015532737004.079236111112572
4155327574015532757404.162083333333786
5155327778015532777804.22093754070
6155327982015532798204.240763888893956
7155328186015532818604.191770833332327
8155328390015532839004.191180555563312
9155328594015532859404.215972222224986

Credits: Thank you Lawrence from South Melbourne, Australia