From 0c18044a46251aeefb66a8145f75d964ccbe691c Mon Sep 17 00:00:00 2001 From: Max Magorsch Date: Sun, 7 Jun 2020 20:39:47 +0000 Subject: Add filters Signed-off-by: Max Magorsch --- html/stats.jinja2 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/html/stats.jinja2 b/html/stats.jinja2 index 98d8474..482a2cf 100644 --- a/html/stats.jinja2 +++ b/html/stats.jinja2 @@ -8,6 +8,13 @@ + @@ -345,6 +352,7 @@ ], "initComplete": function( settings, json ) { setTimeout(function(){ + $('#table_id_length').prepend(""); table.buttons().container().prependTo($('#table_id_length')); $('#table_id_length').prepend(" Show "); document.getElementsByClassName("buttons-colvis")[0].classList = "custom-select custom-select-sm form-control form-control-sm mr-4"; @@ -353,6 +361,29 @@ }); } ); + function addFilters(){ + + if($("#filterRow").length) { + $("#filterRow").remove(); + }else{ + $('#table_id thead tr').clone(true).appendTo('#table_id thead'); + $('#table_id thead tr:eq(1)').attr("id", "filterRow"); + $('#table_id thead tr:eq(1) th').each(function (i) { + var title = $(this).text(); + $(this).html(''); + + $('input', this).on('keyup change', function () { + if (table.column(i).search() !== this.value) { + table + .column(i) + .search(this.value) + .draw(); + } + }); + }); + } + } + -- cgit v1.2.3-18-g5258