对于页面中的数据表:我希望数据表以清晰的状态刷新(无列顺序等),但是如果通过按页面上的后退按钮打开页面,它应该保持其状态。
到目前为止我已经尝试过一些方法,它们是:
1-使用performance.nagivation.type,但无法按照我需要的方式执行它。
// Refresh page, and table with a clear state.
if (performance.navigation.type == 1) {
// some code here
}
// Back key pressed, load parameters and columns.
else if (performance.navigation.type == 2) {
// some code here
}
2-使用drawCallback函数,但它没有像我想象的那样工作。
drawCallback: function() {
if (performance.navigation.type == 1) {
table.state.clear();
}
}
我真的很困惑,无法理解这里出了什么问题。任何帮助都会很棒。
最佳答案
好吧,实际上我做对了,但完全忘记了缓存。当我刷新页面并忽略缓存时。它按我想要的方式工作。
drawCallback: function() {
// When page is refreshed, draw table with clear state.
if (performance.navigation.type == 1)
table.state.clear();
}
关于javascript - 仅刷新数据表页面时如何清除状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58428404/