Skip to content

Commit

Permalink
feat: get table search string from URL before initialising
Browse files Browse the repository at this point in the history
  • Loading branch information
willmclaren committed Jul 24, 2023
1 parent e33d820 commit fb9cc5f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions webapp/src/main/resources/static/src/js/view/HotspotTableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ function HotspotTableView(options)
};
}

function getTableSearchStringFromUrlParams()
{
var parts = window.location.href.split("?");
if(parts.length == 2) {
var params = new URLSearchParams(parts[1]);
return params.get("search");
}
return null;
}

function render()
{
// TODO allow customization of renderer instances
Expand Down Expand Up @@ -345,6 +355,14 @@ function HotspotTableView(options)
dataTableOpts.data = _options.data;
}

// pre-populate the table search field if URL has ?search=some_search_string
var search = getTableSearchStringFromUrlParams();
if(search) {
dataTableOpts.search = {
search: search
};
}

var table = $(_options.el).DataTable(dataTableOpts);

// this is to add more buttons to different locations
Expand Down

0 comments on commit fb9cc5f

Please sign in to comment.