Fixed Header The Only Attribute Not Initializing

Fixed Header The Only Attribute Not Initializing

hickmanjoshickmanjos Posts: 5Questions: 2Answers: 0

I'm having issues getting the Fixed Header extension to actually go into effect when setting up the table.
The DataTables debugger is showing I have it installed, below is how I have initialized the table.

    jQuery(document).ready(function() {
        var table = 
        jQuery('#reports').dataTable({
            "bFilter": true,
            "bInfo": false,
            "bPaginate": false
        });

        $.fn.dataTable.FixedHeader( table );
    });

And my includes(Laravel Blade Syntax):

    {{ HTML::script('js/jquery.dataTables.min.js'); }}
    {{ HTML::script('js/dataTables.fixedHeader.js'); }}

The options I have enabled/disabled are showing so I'm assuming it's simply how I'm trying to initialize the extension.

Any sort of help in the right direction would be awesome!

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    new $.fn.dataTable.FixedHeader( table );

    ^^^

  • hickmanjoshickmanjos Posts: 5Questions: 2Answers: 0
    edited July 2015

    I can't believe I forgot the new! Though even after adding it, it still isn't bringing the header along.

    UPDATE: I'm getting an error while checking in the Chrome Dev Tools of Uncaught TypeError: Cannot read property 'fn' of undefined

    UPDATE 2: Just adding what my init function looks like now.

    <script>
    
        jQuery(document).ready(function() {
            var table = 
            jQuery('#reports').dataTable({
                "bFilter": true,
                "bInfo": false,
                "bPaginate": false
            });
    
            new $.fn.dataTable.FixedHeader( table );
        });
    
    </script>
    
  • hickmanjoshickmanjos Posts: 5Questions: 2Answers: 0

    Got it working!

        jQuery(document).ready(function() {
            var table = 
            jQuery('#reports').dataTable({
                "bFilter": true,
                "bInfo": false,
                "bPaginate": false
            });
    
            new jQuery.fn.dataTable.FixedHeader( table );
        });
    

    Adding the new and changing the last variable definition of $ to jQuery and it works. Now I just have to tinker with the width and the styling to get the headers to match now. (New Issue)

    Thanks for the help, tangerine!

This discussion has been closed.