Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82235

Fixed header not working on first time load(Offset Positions are not get setting properly)

$
0
0

Hi @allan/@colin, I am using DataTable.version = "1.10.16" FixedHeader.version = "3.1.3";

The way Datatable built based on some dropdown value selections calling ajax, it loads some 1000 records are fetched and adding those records through datatable.row.add(record[i]) then calling the datatable.draw(false) to render the table

For the first time load the tableNode offsets are coming as 0 same for thead and tbody.

Suppose if I change the Page Size or the PageNumber then the Offsets are coming correctly
means with based on calculated offsets values, if I come back to the first page the fixed header is working
not during the first time load of the table.

After debugging for long time, figured out in the below function setting positions is getting wrong. can you please help me to fix this issue.

_positions: function ()
    {
        var dt = this.s.dt;
        var table = dt.table();
        var position = this.s.position;
        var dom = this.dom;
        var tableNode = $(table.node()); // For the first time load the tableNode
//offsets are coming as 0 same for thead and tbody.
 
//Suppose if I change the Page Size or the PageNumber
//then the Offsets are coming correctly means with based on calculated offsets values,
//if I come back to the first page the fixed header
//is working not during the first time load of the table
                
        // Need to use the header and footer that are in the main table,
        // regardless of if they are clones, since they hold the positions we
        // want to measure from
        var thead = tableNode.children('thead');
        var tfoot = tableNode.children('tfoot');
        var tbody = dom.tbody;
 
        position.visible = tableNode.is(':visible');
        position.width = tableNode.outerWidth();
        position.left = tableNode.offset().left;
        position.theadTop = thead.offset().top;
        position.tbodyTop = tbody.offset().top;
        position.theadHeight = position.tbodyTop - position.theadTop;
 
        if ( tfoot.length ) {
            position.tfootTop = tfoot.offset().top;
            position.tfootBottom = position.tfootTop + tfoot.outerHeight();
            position.tfootHeight = position.tfootBottom - position.tfootTop;
        }
        else {
            position.tfootTop = position.tbodyTop + tbody.outerHeight();
            position.tfootBottom = position.tfootTop;
            position.tfootHeight = position.tfootTop;
        }
    },

Viewing all articles
Browse latest Browse all 82235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>