Cannot get center to work
Cannot get center to work
miltont
Posts: 20Questions: 7Answers: 0
in TableTools
Hi,
I have the following which works great,
<script>
$(document).ready( function () {
$('#myTable').DataTable(
{
"order":[[1,"desc"],[2,"desc"],[3,"desc"],[4,"desc"]],
"dom":<lif<t>p>',
lengthMenu: [[100,10,25,50,- 1],[100,10,25,50,"All"]],
fixedHeader:{headerOffset:80
}
);
} );
</script>
but every time I try to add the following to center the columns I get an error.
columnDefs: [
{
targets: -1,
className: 'dt-body-right'
}
]
I have 10 columns and would like all columns except the first column to be centered.
All help appreciated.
MiltonT.
This question has accepted answers - jump to:
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
I can't post a test case as it will not work because of the error.
This part works fine:
When I alter it by adding the columnDefs I get an error and the table does not display correctly:
Guessing you are getting a syntax error. Looks like you need a comma and a right brace:
Kevin
Thankyou kthorngren, that addressed my error.
What syntax would I use to mix the column alignments?
i.e.
targets: 0, className: 'dt-body-left'
targets: 1,2,3,5,6,7,8,9, className: 'dt-body-center'
targets: 4, className: 'dt-body-right'
See the Conflict resolution section of the
columnDefs
docs for details of how to provide multiple targets.Kevin
Thanks Kevin, that did the trick!