dataTables fixedColumns part is not working

Between <head> tags:

<script src=""></script> <link rel="stylesheet" type="text/css" href=""/> <link rel="stylesheet" type="text/css" href=""/> <script type="text/javascript" src=""></script> <script type="text/javascript" src=""></script> 

Script:

<script> $(document).ready(function() { var table = $('#example').DataTable( { scrollY: "300px", scrollX: true, scrollCollapse: true, paging: true, fixedColumns: { leftColumns: 2 } } ); } ); </script> 

Table (it has more than 2 rows):

<table cellspacing="0" width="100%"> <thead> <tr> <th>..</th> <th>..</th> <th>..</th> <th>..</th> <th>..</th> <th>..</th> </tr> </thead> <tbody> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> 

CSS:

/* Ensure that the demo table scrolls */ th, td { white-space: nowrap; } div.dataTables_wrapper { width: 100%; margin: 0 auto; } 

Table is working but table has no fixed columns. FixedColumns part is not working.

0

1 Answer

The issue is the libraries are not in right order. Your scripts etc should be like this:

<script type="text/javascript" src=""></script> <script type="text/javascript" src=""></script> 

So basically you just need to make sure to load the main datatables js file before fixedcolumns :)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like