javascript - Get names and visibility of all columns -
i'm using jquery datatables , trying name , visibility of columns in table?
i have tried:
$( 'table' ).datatable().columns().every( function () { console.log( this.data() ) } );
it prints data in table, don't know how access column names , visibility instead of data()
.
i have looked both @ column().nodes()
, columns().every()
cannot find i'm looking for.
solution
you can use column().visible()
column visibility , column().header()
th
node column can use text in header.
for example, consider code below every column data, visibility , header text:
$( 'table' ).datatable().columns().every( function () { // column data console.log("column data", this.data() ); // column visibility console.log("column visibility", this.visible() ); // column header console.log("column header", $(this.header()).text() ); } );
demo
see this jsfiddle code , demonstration.
Comments
Post a Comment