DataTables fixed headers misaligned with columns in wide tables

前端 未结 21 1614
悲&欢浪女
悲&欢浪女 2020-11-30 19:23

Problem

When using the sScrollX, sScrollXInner and/or sScrollY to achieve a fixed header table with its inner content scroll

21条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 20:14

    Add table-layout: fixed to your table's style (css or style attribute).

    The browser will stop applying its custom algorithm to solve size constraints.

    Search the web for infos about handling column widths in a fixed table layout (here are 2 simple SO questions : here and here)

    Obviously: the downside will be that your columns' width won't adapt to their content.


    [Edit] My answer worked when I used the FixedHeader plugin, but a post on the datatable's forum seem to indicate that other problems arise when using the sScrollX option :

    bAutoWidth and sWidth ignored when sScrollX is set (v1.7.5)

    I'll try to find a way to go around this.

提交回复
热议问题