Filter control clears if table data is refreshed when height is defined
Bootstraptable version(s) affected
1.24.1
Description
When using the filter control and a data height is set, if the refresh button is used, it clears the filter. In example, search for 'item 1' and then press the refresh button. The filter will empty after the refresh. If the data height is removed then on refresh the page retains the filter control entries
Example(s)
https://live.bootstrap-table.com/code/robertfshort/18793
Possible Solutions
No response
Additional Context
plausibly, could be related to the control filter losing focus when things are typed into it. IE, in my example, if you search for 'item' and then stop typing it moves the cursor back to the beginning of the word 'item'
Also plausibly related to #6978
still exist in 1.25.0 It maybe a mistake in bootstrap-table-filter-control.js file at 5807 line:
function cacheValues(that) { var searchControls = getSearchControls(that); that._valuesFilterControl = []; searchControls.each(function () { var $field = $(this); var fieldClass = escapeID(getElementClass($field)); if (that.options.height && !that.options.filterControlContainer) { $field = that.$el.find(".fixed-table-header .".concat(fieldClass)); // =======> this line } else if (that.options.filterControlContainer) { $field = $("".concat(that.options.filterControlContainer, " .").concat(fieldClass)); } else { $field = that.$el.find(".".concat(fieldClass)); } that._valuesFilterControl.push({ field: $field.closest('[data-field]').data('field'), value: $field.val(), position: getCursorPosition($field.get(0)), hasFocus: $field.is(':focus') }); }); } change line $field = that.$el.find(".fixed-table-header .".concat(fieldClass)); to $field = that.$tableContainer.find(".fixed-table-header .".concat(fieldClass));
replace $el to $tableContainer, and then work fine.