-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
BootstrapTable.prototype.onColumnSearch makes 3 requests #1605
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
Comments
@Pilb - more detail please Ideally include all relevant header and response info from each, or at least url and summary of it so we see what they were Also please include copy of your html and js related to this plugin thanks |
Please find example here : https://jsfiddle.net/gr24ouqo/4/. Try to enter text into column filter and you will see 3 requests on network. BootstrapTable.prototype.onColumnSearch = function (event) {
copyValues(this);
var text = $.trim($(event.currentTarget).val());
var $field = $(event.currentTarget).parent().parent().parent().data('field')
if ($.isEmptyObject(this.filterColumnsPartial)) {
this.filterColumnsPartial = {};
}
if (text) {
this.filterColumnsPartial[$field] = text;
} else {
delete this.filterColumnsPartial[$field];
}
this.options.pageNumber = 1;
this.onSearch(event); // First Request
this.updatePagination(); // Second Request
this.trigger('column-search', $field, text); // Third Request
}; Thanks, Pilb |
Not much time to look atm, but here is what i found EDIT i first thought appears to make as many (duplicate) requests as there are columns, even if filter attribute not set on some, as i saw 2 requests only appear after disabling one field, but then saw 3 requests appear again each time later... Here is updated fiddle: https://jsfiddle.net/dabros/gr24ouqo/5/ I also included https://rawgit.com/wenzhixin/bootstrap-table/master/src/extensions/filter-control/bootstrap-table-filter-control.js inline ('in header no-wrap' option selected) so changes can be quickly modded, though better to fork repo and point to that if you plan on pull request though. This appears to be where the handlers are added: if (addedFilterControl) {
header.off('keyup', 'input').on('keyup', 'input', function (event) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnSearch(event);
}, that.options.searchTimeOut);
});
header.off('change', 'select').on('change', 'select', function (event) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnSearch(event);
}, that.options.searchTimeOut);
});
header.off('mouseup', 'input').on('mouseup', 'input', function (event) {
var $input = $(this),
oldValue = $input.val();
if (oldValue === "") {
return;
}
setTimeout(function(){
var newValue = $input.val();
if (newValue === "") {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnSearch(event);
}, that.options.searchTimeOut);
}
}, 1);
});
if (header.find('.date-filter-control').length > 0) {
$.each(that.columns, function (i, column) {
if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'datepicker') {
header.find('.date-filter-control.' + column.field).datepicker(column.filterDatepickerOptions)
.on('changeDate', function (e) {
//Fired the keyup event
$(e.currentTarget).keyup();
});
}
});
}
} else {
header.find('.filterControl').hide();
}
};
But that doesnt strike me as wrong at all, so problem prob elsewhere in filter-control code. @djhvscf might know more, but i cant see anything jumping out at me - next question is can we confirm this relates only to filter-control, and not quirk of base code that either always there or triggered by filter-control interacting like this??? |
mayble related: #1501 |
Hi Dennis, |
Until now this issue is opened because we don't have any patch for it.. If you have one please open a new PR @javieralfaya |
Hi Dennis, this is may patch: Table filter control when pagination on server submit response twice, i commented this.update Pagination(); into bootstrap-table-filter-control.js and problem is resolved: BootstrapTable.prototype.onColumnSearch = function (event) {
}; |
Great! Then open a new PR please, @javieralfaya |
@javieralfaya - PR are always welcome https://github.com/wenzhixin/bootstrap-table/blob/master/CONTRIBUTING.md |
There was an incompatibility between the cookies extension and the filter control extension, which resulted in the following behavior: every time that a cookie was found, it would be added to a list of filter, and it would query the database again. This would result in (for example) a series of three filters to force three separate database calls, each database call accumulating the last. This update fixes this issue. it also incorporates the change from issue wenzhixin#1605 -- in which updatePagination is called by onSearch(), but both are included in the onColumnSearch() function, causing the table to double all calls to the database.
There was an incompatibility between the cookies extension and the filter control extension, which resulted in the following behavior: every time that a cookie was found, it would be added to a list of filter, and it would query the database again. This would result in (for example) a series of three filters to force three separate database calls, each database call accumulating the last. This update fixes this issue. it also incorporates the change from issue wenzhixin#1605 -- in which updatePagination is called by onSearch(), but both are included in the onColumnSearch() function, causing the table to double all calls to the database.
still facing this problem. i am using 1.10.1 |
Please update to 1.11.0 |
Still does it in version: 1.12.1 |
Hi,
Using bootstrap-table-filter-control.js, on server side, 3 requests were sent to server.
Thanks.
The text was updated successfully, but these errors were encountered: