basetable.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {% extends "base.html" %}
  2. {% block pagecontent %}
  3. <script>
  4. function showhideTableColumn(i, sh) {
  5. if (sh)
  6. $('td:nth-child('+i+'),th:nth-child('+i+')').show();
  7. else
  8. $('td:nth-child('+i+'),th:nth-child('+i+')').hide();
  9. }
  10. function filterTableRows(test) {
  11. if (test.length > 0) {
  12. var r = test.split(/[ ,]+/).map(function (e) { return new RegExp(e, 'i') });
  13. $('tr.data').map( function (i, el) {
  14. (! r.map(function (j) { return j.test($(el).html())}).reduce(function (c, p) { return c && p;} )) ? $(el).hide() : $(el).show();
  15. });
  16. } else
  17. {
  18. $('tr.data').show();
  19. }
  20. }
  21. </script>
  22. <div style="margin-bottom: 0.5em">
  23. {% block pagename %}
  24. {% endblock %}
  25. <div align="left" style="display:inline-block; width: 40%; margin-left: 2em"> Search: <input type="search" id="filterstring" style="width: 80%" onkeyup="filterTableRows($('#filterstring').val())" autocomplete="off">
  26. </div>
  27. {% if hideshowcols %}
  28. <div align="right" style="display: inline-block; width: 40%">Show/Hide columns:
  29. {% for i in hideshowcols %}
  30. <span>{{i.name}} <input type="checkbox" id="ct{{i.name}}" onchange="showhideTableColumn({{i.order}}, $('#ct{{i.name}}').is(':checked'))" checked autocomplete="off"></span> |
  31. {% endfor %}
  32. </div>
  33. {% endif %}
  34. </div>
  35. <div>
  36. <table class="table table-striped table-condensed" style="width:95%">
  37. {% block pagetable %}
  38. {% endblock %}
  39. </table>
  40. </div>
  41. {% endblock %}