Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always update filter widgets with preset searchCols #1115

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- `updateSearch()` now sets the slider values based on the new search string for numeric columns (thanks, @mikmart, #1110).

- The `searchCols` option now sets the slider values for numeric columns when `server = TRUE` (thanks, @alexvpickering, @mikmart, #998).

- Added server-side processing support for the [SearchBuilder](https://datatables.net/extensions/searchbuilder/) extension (thanks, @AhmedKhaled945, @shrektan, @mikmart, #963).

# CHANGES IN DT VERSION 0.31
Expand Down
13 changes: 2 additions & 11 deletions inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ HTMLWidgets.widget({
table.draw(); // redraw table, and filters will be applied
}
});
if (searchCol) filter[0].selectize.setValue(JSON.parse(searchCol));
filter[0].selectize.on('blur', function() {
$x.hide().trigger('hide'); $input.parent().show(); $input.trigger('blur');
});
Expand Down Expand Up @@ -702,7 +701,7 @@ HTMLWidgets.widget({
// processing
if (server) {
// if a search string has been pre-set, search now
if (searchCol) searchColumn(i, searchCol).draw();
if (searchCol) $input.trigger('input').trigger('change');
return;
}

Expand Down Expand Up @@ -748,15 +747,7 @@ HTMLWidgets.widget({
$.fn.dataTable.ext.search.push(customFilter);

// search for the preset search strings if it is non-empty
if (searchCol) {
if (inArray(type, ['factor', 'logical'])) {
filter[0].selectize.setValue(JSON.parse(searchCol));
} else if (type === 'character') {
$input.trigger('input');
} else if (inArray(type, ['number', 'integer', 'date', 'time'])) {
$input.trigger('change');
}
}
if (searchCol) $input.trigger('input').trigger('change');

});

Expand Down