bootstrap-table
bootstrap-table copied to clipboard
pipeline with advanced search
Description
I'm the original developer of the pipeline extension. This extension never supported the filter-control or advanced search extension. I'm trying to add advanced search support, but the code has been refactored pretty extensively since I initially wrote this.
I'm requesting some help getting a certain piece of this to work.
Whenever the "Advanced Search" modal is closed with the "btnClosedAvd_*" click event, I need the pipeline's code to recognize this so it can "reset the cache". This will force a fresh server side query (like how pipelining currently works for regular searching, sorting and paging-out).
The way I do this currently with pipelining is to override the corresponding function, reset the cache if pipelining is used and then call the parent function. For example, for searching:
var _onSearch = BootstrapTable.prototype.onSearch;
...
BootstrapTable.prototype.onSearch = function () {
/* force a cache reset on search */
if (this.options.usePipeline) {
this.resetCache = true;
}
_onSearch.apply(this, Array.prototype.slice.apply(arguments));
};
So later when the parent onSearch eventually calls initServer
in the pipeline extension, it will see that this.resetCache = true
.
For advanced search, I haven't found a similar hook. I only want to be notified when the modal is hidden with the "Close" button (not the X). In the toolbar extensions hideAlert()
function, there's this code:
if (this.options.sidePagination === 'server') {
this.options.pageNumber = 1;
this.updatePagination();
this.trigger('column-advanced-search', this.filterColumnsPartial);
}
This is where the advanced-search modal is "submitted" and the filters applied for server side paginiation. this.updatePagniation()
will eventually call pipeline's initServer()
. It's here I can add a hook that can be overridden in pipeline:
// bootstrap-table-toolbar.js
}, {
key: "onSubmitAdvancedSearch",
value: function onSubmitAdvancedSearch(e) {
// called on server side pagination after close but before
// updatePagination()
return true;
}
},
// hideAlert()
if (this.options.sidePagination === 'server') {
this.onSubmitAdvancedSearch();
this.options.pageNumber = 1;
this.updatePagination();
this.trigger('column-advanced-search', this.filterColumnsPartial);
}
// bootstrap-table-pipeline.js
var _onSubmitAdvancedSearch = BootstrapTable.prototype.onSubmitAdvancedSearch;
BootstrapTable.prototype.onSubmitAdvancedSearch = function () {
/* force a cache reset on advanced search */
if (this.options.usePipeline) {
this.resetCache = true;
}
_onSubmitAdvancedSearch.apply(this, Array.prototype.slice.apply(arguments));
};
But when this.onSubmitAdvancedSearch()
is being called from toolbar's hideAlert()
it's not calling the overridden one in pipeline. It doesn't matter which order I import the extensions. Is there a way to get this to work?
Thanks!