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)
1150798186015079818603.024865
2150798378015079837803.063444
3150798570015079857003.13343
4150798762015079876203.161078
5150798954015079895403.224576
6150799146015079914603.273617
7150799338015079933803.3253
8150799530015079953003.32269
9150799722015079972203.372206

Credits: Thank you Lawrence from South Melbourne, Australia