mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Fixed behavior of datatables fixedHeader on subsequent ajax calls.
This commit is contained in:
parent
c8bfe7f6d4
commit
f22d65cd24
1 changed files with 12 additions and 2 deletions
|
@ -81,13 +81,12 @@ export default class extends Controller {
|
|||
//Add url info, as the one available in the history is not enough, as Turbo may have not changed it yet
|
||||
settings.url = this.element.dataset.dtUrl;
|
||||
|
||||
|
||||
let options = {
|
||||
colReorder: true,
|
||||
responsive: true,
|
||||
fixedHeader: {
|
||||
header: $(window).width() >= 768, //Only enable fixedHeaders on devices with big screen. Fixes scrolling issues on smartphones.
|
||||
headerOffset: $("#navbar").height()
|
||||
headerOffset: $("#navbar").outerHeight()
|
||||
},
|
||||
buttons: [{
|
||||
"extend": 'colvis',
|
||||
|
@ -133,6 +132,11 @@ export default class extends Controller {
|
|||
dt.on('select.dt deselect.dt', this._onSelectionChange.bind(this));
|
||||
});
|
||||
|
||||
promise.then((dt) => {
|
||||
//Recalculate the fixed header offset, as the navbar should be rendered now
|
||||
dt.fixedHeader.headerOffset($("#navbar").outerHeight());
|
||||
});
|
||||
|
||||
//Allow to further configure the datatable
|
||||
promise.then(this._afterLoaded.bind(this));
|
||||
|
||||
|
@ -140,6 +144,12 @@ export default class extends Controller {
|
|||
console.debug('Datatables inited.');
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
//Destroy the datatable element
|
||||
this._dt.destroy();
|
||||
console.debug("Datatables destroyed.");
|
||||
}
|
||||
|
||||
_rowCallback(row, data, index) {
|
||||
//Set the row class based on the optional $$rowClass column data, can be used to color the rows
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue