How to Initialize variable number of columns where all columns are sortable
How to Initialize variable number of columns where all columns are sortable
kevhan999
Posts: 1Questions: 0Answers: 0
Hi,
I have a table that has variable number of columns with sorting needed and would like to know how to initialize. I initialize datatables with the following api call, but this same table could have 6 columns (all sortable). Is there a generic easy way to initialize 'x' number of sortable columns?
ads_table = $('#ads-table').DataTable({
//"pagingType": "full_numbers",
"oLanguage":
{
sLengthMenu: "Ads per page _MENU_",
"oPaginate":
{
"sNext": '>',
"sLast": '>|',
"sFirst": '|<',
"sPrevious": '<'
}
},
"bSort" : true,
"bAutoWidth": false,
"aoColumnDefs": [
{ "bSortable": false, 'aTargets':[0,2] }
],
"order": [[ 1, "asc" ],[ 2, "asc" ],[ 3, "asc" ]],
"columns": [
{"width": "10px"},
{"width": "25%"},
{"width": "40%"},
{"width": "10%"},
{"width": "10%"},
{"width": "auto"},
{"width": "5%"},
{"width": "auto"}
],
"sDom":'lptpli'
});
This discussion has been closed.
Replies
Why not consider hiding columns you don't intend to show? Before you display your table, check to see what state it needs to be in.