Skip to content

Commit 91f5ab8

Browse files
authored
Merge pull request #193 from nexB/181-clear-datatable-filter-value
Remove filter value when new file loaded #181
2 parents 4cb9f91 + d24c05b commit 91f5ab8

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

assets/js/renderer.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ $(document).ready(function () {
598598
});
599599
}
600600

601+
// Show files that contain attribute value selected by user in bar chart
601602
function chartSummaryToFiles() {
602603
const val = $(this).data("value");
603604

@@ -608,13 +609,7 @@ $(document).ready(function () {
608609
column.visible(true);
609610

610611
// Clear all other columns
611-
$.each(AboutCodeDataTable.TABLE_COLUMNS, (i, column) => {
612-
const columnSelect = $(`select#clue-${column.name}`);
613-
columnSelect.val("");
614-
cluesTable.dataTable
615-
.column(`${column.name}:name`)
616-
.search("", false, false);
617-
});
612+
clearClueDataTableFilterValue();
618613

619614
// Get the column's filter select box
620615
const select = $(`select#clue-${columnName}`);
@@ -630,6 +625,17 @@ $(document).ready(function () {
630625
}
631626
}
632627

628+
// Clear all column filter that are set in clue DataTable
629+
function clearClueDataTableFilterValue() {
630+
$.each(AboutCodeDataTable.TABLE_COLUMNS, (i, column) => {
631+
const columnSelect = $(`select#clue-${column.name}`);
632+
columnSelect.val("");
633+
cluesTable.dataTable
634+
.column(`${column.name}:name`)
635+
.search("", false, false);
636+
});
637+
}
638+
633639
// Open a SQLite Database File
634640
function openSQLite() {
635641
dialog.showOpenDialog({
@@ -642,6 +648,7 @@ $(document).ready(function () {
642648
}, function(fileNames) {
643649
if (fileNames === undefined) return;
644650
loadDatabaseFromFile(fileNames[0]);
651+
clearClueDataTableFilterValue();
645652
});
646653
}
647654

@@ -772,6 +779,7 @@ $(document).ready(function () {
772779
alert(`Error: ${err.message ? err.message : err}`);
773780
});
774781
});
782+
clearClueDataTableFilterValue();
775783
}).fail(function (jqxhr, textStatus, error) {
776784
// Show error for problem with the JSON file
777785
dialog.showErrorBox(

0 commit comments

Comments
 (0)