JCI and TableSorter
Your task:
Display JSON data in the browser in a table that the user can sort. Solution:
Install JCI-Plugin and the plugin “Table Sorter“
Example-Code:
Original JSON:
https://api.blockchain.info/charts/transactions-per-second?timespan=5weeks&rollingAverage=8hours&format=json
Locally stored:
http://api.json-content-importer.com/extra/json/api.blockchain.info.json
Create a new JCI-Template:
- URL:
http://api.json-content-importer.com/extra/json/api.blockchain.info - Method: PHP-RAWGET
- twig-template:
{{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)</th>
</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>
In action: