Fixed data table height

Fixed data table height

wouterstevenwoutersteven Posts: 8Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
Good day all,

I'm very pleasantly surprised with Data Tables, however have two questions that I couldn't find an answer to in the examples.

1. Is it possible to set a fixed height to the table, for example 250 pixels or 10 rows, so that when there are less than 10 rows, the table size remains the same and doesn't resize to smaller?

2. Is it possible to disable sorting for certain columns?

Sincerely,
- Wouter van der Schagt

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Wouter,

    1. Yes - just use a little bit of CSS to do this: .dataTables_wrapper { min-height: 250px; }

    2. Yes - use bSortable : false

    Allan
  • ValkyValky Posts: 5Questions: 0Answers: 0
    edited April 2012
    Hi Wouter,

    I am currently adjusting the CSS, to have a 100% height of the rows container, perhaps it could help you :

    CSS
    [code]
    html,body {margin:0;padding:0;overflow:hidden;height:100%;}
    #main_div_container {width:100%;position:relative;height:100%;margin:auto;}
    #yourDataTable_container {position:absolute;top:0px;bottom:0px;left:0px;right:0px;}
    #yourDataTable_ID {padding-bottom:30px;}
    .dataTables_wrapper {position:absolute;top:40px;bottom:0px;left:0px;right:0px;}
    .dataTables_scrollHead {position:relative;top:0px;}
    .dataTables_scrollBody {position:absolute;top:56px;bottom:0px;}
    .dataTables_scrollFoot {position:absolute;bottom:14px;background-color:#(your background color);padding-bottom:2px;}
    [/code]

    HTML
    [code]

    ...




    ...




    [/code]
  • wouterstevenwoutersteven Posts: 8Questions: 0Answers: 0
    Hi, thank you for the suggestions...I have most of it working now :)
  • wouterstevenwoutersteven Posts: 8Questions: 0Answers: 0
    The bSortable is working, but the height not yet...I'm looking for a way to make the table 300 pixels high, even if there is only 1 or 2 row, without making the rows bigger, so in effect, fill up the table with a number of empty rows?
This discussion has been closed.