Add saveState/loadState callbacks

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2020-05-22 13:27:52 +01:00
committed by XhmikosR
parent 6b1340cfdf
commit eb05394b66
+42 -2
View File
@@ -175,7 +175,27 @@ $(document).ready(function () {
scrollY: "200px",
scrollX: true,
order: [[2, "asc"]],
stateSave: true
stateSave: true,
stateSaveCallback: function(settings, data) {
// Store current state in client's local storage area
localStorage.setItem("activeDhcpLeaseTable", JSON.stringify(data));
},
stateLoadCallback: function() {
// Receive previous state from client's local storage area
var data = localStorage.getItem("activeDhcpLeaseTable");
// Return if not available
if (data === null) {
return null;
}
data = JSON.parse(data);
// Always start on the first page to show most recent queries
data.start = 0;
// Always start with empty search field
data.search.search = "";
// Apply loaded state to table
return data;
}
});
}
@@ -188,7 +208,27 @@ $(document).ready(function () {
scrollY: "200px",
scrollX: true,
order: [[2, "asc"]],
stateSave: true
stateSave: true,
stateSaveCallback: function(settings, data) {
// Store current state in client's local storage area
localStorage.setItem("staticDhcpLeaseTable", JSON.stringify(data));
},
stateLoadCallback: function() {
// Receive previous state from client's local storage area
var data = localStorage.getItem("staticDhcpLeaseTable");
// Return if not available
if (data === null) {
return null;
}
data = JSON.parse(data);
// Always start on the first page to show most recent queries
data.start = 0;
// Always start with empty search field
data.search.search = "";
// Apply loaded state to table
return data;
}
});
}