Skip to content

Commit

Permalink
Bypass character search throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikmart committed Jan 13, 2024
1 parent 7866c12 commit 6f13164
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions inst/htmlwidgets/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ HTMLWidgets.widget({
var v1 = JSON.stringify(filter[0].selectize.getValue()), v2 = $input.val();
if (v1 === '[]') v1 = '';
if (v1 !== v2) filter[0].selectize.setValue(v2 === '' ? [] : JSON.parse(v2));
},
updatesearch: function() {
$input.trigger('input');
}
});
var $input2 = $x.children('select');
Expand Down Expand Up @@ -533,7 +536,13 @@ HTMLWidgets.widget({
if (server) {
fun = $.fn.dataTable.util.throttle(fun, options.searchDelay);
}
$input.on('input', fun);
$input.on({
input: fun,
updatesearch: function() {
// Bypass any throttling.
searchColumn(i, $input.val()).draw();
}
});
} else if (inArray(type, ['number', 'integer', 'date', 'time'])) {
var $x0 = $x;
$x = $x0.children('div').first();
Expand Down Expand Up @@ -617,6 +626,10 @@ HTMLWidgets.widget({
if (v[0] != slider_min()) v[0] *= scale;
if (v[1] != slider_max()) v[1] *= scale;
filter.val(v);
},
updatesearch: function () {
$input.trigger('input'); // Resets slider if search is empty.
$input.trigger('change');
}
});
var formatDate = function(d, isoFmt) {
Expand Down Expand Up @@ -1402,9 +1415,7 @@ HTMLWidgets.widget({
console.log('The search keyword for column ' + i + ' is undefined')
return;
}
// Update column search string and values on linked filter widgets.
// 'input' for factor and char filters, 'change' for numeric filters.
$(td).find('input').first().val(v).trigger('input').trigger('change');
$(td).find('input').first().val(v).trigger('updatesearch');
});
table.draw();
}
Expand Down

0 comments on commit 6f13164

Please sign in to comment.