DataTables / FixedHeader

Fix the header, footer, left or right columns of a table in place, to always show them when scrolling
http://www.datatables.net/
Other
75 stars 83 forks source link

Allow to configure fixed element container #89

Open althaus opened 7 years ago

althaus commented 7 years ago

We've got still some issues with form and FixedHeader/Footer (#68). Wouldn't it be sufficient to make the container configurable? At the moment the floating footer get's appended to body. If we'd move it out of the table into the surrounding form it'll still work out-of-the-box:

Before DT triggers:

<body>
    <form>
        <table>
            <tbody><!-- some rows --></tbody>
            <tfoot><!-- some actions --></tfoot>
        </table>
    </form>
</body>

Current version:

<body>
    <form>
        <table>
            <tbody><!-- some rows --></tbody>
        </table>
    </form>
    <table>
        <tfoot><!-- some actions --></tfoot>
    </table>
</body>

Alternate solution:

<body>
    <form>
        <table>
            <tbody><!-- some rows --></tbody>
        </table>
        <table>
            <tfoot><!-- some actions --></tfoot>
        </table>
    </form>
</body>

https://github.com/DataTables/FixedHeader/blob/master/js/dataTables.fixedHeader.js#L285

Cheers Matthias

DataTables commented 7 years ago

For the most part the position of the fixed element in the DOM doesn't actually matter (since it is position: fixed). However, at the transition point when the table gets to the top of the page and the header has to scroll off, it needs to be position: absolute for that to work. At that point the positioning in the DOM is important. I used body because it simplifies things a lot. It probably would be possible to put it in next to the DataTable itself using the correct offset parent.

If that is implemented it would be easier to just make that the method used rather than providing an option for the container.

althaus commented 7 years ago

I'd be fine with that. Dunno if someone needs to rely on the body-placement and changing the DOM position would be a BC break now.