How to give options in dataTables based on javascript variables?
How to give options in dataTables based on javascript variables?
arpitsinghal
Posts: 3Questions: 0Answers: 0
I want to do something like following:
I need to initialize multiple DataTables on a single page. And I would need to turn on/off pagination by using a value from a javascript variable. One way is to duplicate the datatable initializing code code within if else javascript. Is there simple way to use javascript if else within datatable initialization. Thanks.
I need to initialize multiple DataTables on a single page. And I would need to turn on/off pagination by using a value from a javascript variable. One way is to duplicate the datatable initializing code code within if else javascript. Is there simple way to use javascript if else within datatable initialization. Thanks.
This discussion has been closed.
Replies
[code]
var paging = false;
$('#example').dataTable( {
bPaginate: paging
} );
[/code]
Allan
I am also interested in learning how to dynamically change which options are assigned in the datatable initialization code.
I can easily do what Allen had suggested for adjusting certain option parameters, but am interested in finding out how to have an option removed completely.
Example:
[code]
$('#example').dataTable( {
"bPaginate": true,
"aaSorting": [[ 2, 'desc' ]],
"aaSortingFixed": [[0,'asc']]
} );
[/code]
So in the previous example, how would one go about removing the fixed sorting option or disabling it completely when a certain condition is met.
Sorry if I am hijacking the thread, but I thought that perhaps arpitsinghal's issue may be similar to what I was trying to accomplish.
Thanks.
"aaSortingFixed": condition ? [[0,'asc']] : []
[/code]
Allan
Thank You.
Allan