How to fix/pin/freeze header and 1. row when sorting?

How to fix/pin/freeze header and 1. row when sorting?

bluepuma77bluepuma77 Posts: 1Questions: 1Answers: 0

I would like to have a pinned header (with sort arrows) and a pinned first row. Is that possible?

Name ^    | Date ^               Name .    | Date ^
New [   ] | [   ]                New [   ] | [   ]
Adam      | 01.01.1980           Eve       | 31.12.1980
Eve       | 31.12.1980           Adam      | 01.01.1980

I searched for "pinned" and "freeze", tried fixedRows: { top: 2 } (doesn't work) and set the 1. row as header, too (it gets sort arrows). How to fix header and 1. row when sorting?

Answers

  • kthorngrenkthorngren Posts: 21,352Questions: 26Answers: 4,955
    edited January 2022

    You can use FixedHeader to fix the header. I don't believe FixedHeader supports multiple header rows you won't be able to place your New row in the header.

    Datatables doesn't have a way to pin/freeze a row. You can use the plugin described in this blog to augment Datatables sorting to force certain rows to the top row. However that row won't remain visible if changing pages or using scrollX.

    If you don't need FixedHeader you can create two header rows and have the second for the New row and the first for sorting using orderCellsTop. See this Complex header example.

    Kevin

Sign In or Register to comment.