datatable hide column, initial sort and sort first column using values from second column
datatable hide column, initial sort and sort first column using values from second column
HI!
I have table with 7 columns
<th><h5>Doc</h5></th>
<th><h5>No</h5></th>
<th><h5>Customer</h5></th>
<th><h5>Date</h5></th>
<th><h5>Due ate</h5></th>
<th><h5>Status</h5></th>
<th><h5>Options</h5></th>
my DataTable init is:
$(".data-table-class").DataTable( {
"language": {
"lengthMenu": "_MENU_ ",
"zeroRecords": "no data",
"info": "pg. _PAGE_ of _PAGES_",
"infoEmpty": "no data",
"loadingRecords": "loading...",
"search": "search:",
"paginate": {
"first": "|<",
"last": ">|",
"next": ">",
"previous": "<"
},
"aria": {
"sortAscending": ": asc",
"sortDescending": ": desc"
},
"order": [[ 1, "desc" ]],
"columnDefs": [
{
"targets": [0],
"visible": true,
"orderable": false,
"searchable": false
},
{
"targets": [1],
"visible": false,
"searchable": false
}],
"stateSave": true
}
} );
I want to:
- order by data from second column [No] on load
- hide second column [No]
- allow sort first column [Doc] using values from second column [No]
- remove sorting from columns: Doc, Options
I've tried to manipulate witg columns and columnDefs byt with no success - hiding, removing sorting and initial sort don't work
what am I doing wrong?
any help?
my current version: cdn.datatables.net/1.10.20
THANK YOU!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Looks like you have all the Datataubles options within the
languageoption. Move theorder,columnDefsandstateSaveoutside thelanguageoption, ie, after the}in line 33.Kevin
yap - this works!
but how to sort first column usig data from hidden [second] column?
I've solved that
thanks for help