Skip to content

Commit

Permalink
Fix: Account for SearchPanes in nested tables - events bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanJard committed Jun 1, 2022
1 parent 1fb4934 commit 6e5740c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/SearchPanes.ts
Expand Up @@ -134,8 +134,14 @@ export default class SearchPanes {
this._getState();

if (this.s.dt.page.info().serverSide) {
var hostSettings = this.s.dt.settings()[0];

// Listener to get the data into the server request before it is made
this.s.dt.on('preXhr.dtsps', (e, settings, data) => {
if (hostSettings !== settings) {
return;
}

if (data.searchPanes === undefined) {
data.searchPanes = {};
}
Expand Down Expand Up @@ -353,6 +359,7 @@ export default class SearchPanes {
* Set's the xhr listener so that SP can extact appropriate data from the response
*/
protected _setXHR(): void {
var hostSettings = this.s.dt.settings()[0];
var run = json => {
if (json && json.searchPanes && json.searchPanes.options) {
this.s.serverData = json;
Expand All @@ -364,7 +371,9 @@ export default class SearchPanes {
// We are using the xhr event to rebuild the panes if required due to viewTotal being enabled
// If viewTotal is not enabled then we simply update the data from the server
this.s.dt.on('xhr.dtsps', (e, settings, json) => {
run(json);
if (hostSettings === settings) {
run(json);
}
});

// Account for the initial JSON fetch having already completed
Expand Down

0 comments on commit 6e5740c

Please sign in to comment.