Datatables 清除JQuery数据表本地存储
如何以编程方式清除Jquery数据表本地存储 clear()清除所有本地存储 但我需要特别清除datatable值。Datatables 清除JQuery数据表本地存储,datatables,local-storage,Datatables,Local Storage,如何以编程方式清除Jquery数据表本地存储 clear()清除所有本地存储 但我需要特别清除datatable值。 <i class="fas fa-sync-alt RefreshButtonDataTable" onclick="ClearDataTableStorageAndRefresh()"></i> <script> function ClearDataTableStorageAndRefresh() {
<i class="fas fa-sync-alt RefreshButtonDataTable" onclick="ClearDataTableStorageAndRefresh()"></i>
<script>
function ClearDataTableStorageAndRefresh() {
ClearLocalStorageDataTables_tbl();
$('#tbl_SearchTasks').DataTable().ajax.reload();
}
</script>
function ClearLocalStorageDataTables_tbl() {
debugger;
var arr = []; // Array to hold the keys
// Iterate over localStorage and insert the keys that meet the condition into arr
for (var i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).substring(0, 14) == 'DataTables_tbl') {
arr.push(localStorage.key(i));
}
}
// Iterate over arr and remove the items by key
for (var i = 0; i < arr.length; i++) {
localStorage.removeItem(arr[i]);
}
new Noty({
type: 'success',
theme: 'metroui',
layout: 'bottomRight',
text: 'Datatable Temporary Storage Cleared',
progressBar: true,
timeout: 5000
}).show();
}
函数ClearDataTablesStorage和Fresh(){
ClearLocalStorageDataTables_tbl();
$('#tbl_SearchTasks').DataTable().ajax.reload();
}
函数ClearLocalStorageDataTables\u tbl(){
调试器;
var arr=[];//保存键的数组
//迭代localStorage并将满足条件的密钥插入arr
for(var i=0;i