Skip to content

Commit ee140cd

Browse files
committed
fix: completamento migrazione datatables.net-bs
1 parent 863df71 commit ee140cd

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

assets/src/css/datatables.css

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ table.dataTable thead th.sorting:after,
3636
table.dataTable thead th.sorting_asc:after,
3737
table.dataTable thead th.sorting_desc:after {
3838
position: absolute;
39-
top: 12px;
39+
top: 20px;
4040
right: 8px;
4141
display: block;
4242
font-family: FontAwesome;
@@ -64,15 +64,6 @@ div.dataTables_scrollBody table.dataTable thead th.sorting_desc:after {
6464
}
6565

6666

67-
/* In Bootstrap and Foundation the padding top is a little different from the DataTables stylesheet */
68-
69-
table.table thead th.sorting:after,
70-
table.table thead th.sorting_asc:after,
71-
table.table thead th.sorting_desc:after {
72-
top: 8px;
73-
}
74-
75-
7667
/*
7768
* DataTables style pagination controls
7869
*/

assets/src/js/functions/datatables.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function start_datatables( $elements ) {
6262
const single_value = search[(id_plugin ? id_plugin : "") + "_search_" + id] ? search[(id_plugin ? id_plugin : "") + "_search_" + id] : "";
6363

6464
column_search.push({
65-
"sSearch": single_value,
65+
"search": single_value,
6666
});
6767
});
6868

@@ -78,8 +78,8 @@ function start_datatables( $elements ) {
7878
deferRender: true,
7979
ordering: true,
8080
searching: true,
81-
aaSorting: [],
82-
aoSearchCols: column_search,
81+
order: [],
82+
searchCols: column_search,
8383
scrollY: "60vh",
8484
scrollX: '100%',
8585
retrieve: true,
@@ -287,13 +287,20 @@ function initComplete(settings) {
287287
const $this = $(this);
288288
const search = getTableSearch();
289289

290-
api.columns('.search').every(function () {
290+
// In DataTables 2.x, il selettore .search potrebbe non funzionare come previsto
291+
// Usiamo un approccio più robusto basato sugli ID delle colonne
292+
api.columns().every(function () {
291293
const column = this;
294+
const header = $(column.header());
295+
296+
// Verifica se la colonna ha la classe 'search'
297+
if (!header.hasClass('search')) {
298+
return;
299+
}
292300

293301
// Valore predefinito della ricerca
294302
let tempo;
295303
const id_plugin = $this.data('idplugin');
296-
const header = $(column.header());
297304
const name = header.attr('id').replace('th_', '');
298305

299306
const value = search[(id_plugin ? id_plugin : "") + "_search_" + name] ? search[(id_plugin ? id_plugin : "") + "_search_" + name] : '';

0 commit comments

Comments
 (0)