table height depending on 'entries shown' parameter

table height depending on 'entries shown' parameter

mfreremfrere Posts: 4Questions: 0Answers: 0
edited June 2012 in General
Hi,
I'd like to make my datatable height depend on the "entries shown" parameter, even when filtering or reaching the end of pagination.
I read a few forum discussions already and it seems there is a way to do this by adding a div using 'sDom'.
eg: http://datatables.net/forums/discussion/2621/table-height-when-filtered-or-for-last-page/p1

So if I get this right, I'll have to update that div every time the amount of entries shown gets changed?
I thinks this is doable but looks like a moderately complicated solution. At the moment, I let the plugin take care of the height of the rows, so I would need to somehow grab that height, then multiply by the amount of entries shown and apply it to the div on some 'onEntriesShownChange' event. Once this is done, I guess I should prey the css/js gods that this solution works cross-browser.

I'm not complaining, I'm willing to do this if it's the only way. The plugin is great and will probably save me a lot of time but I was wondering... Is there a simpler way? If not, this could make a very good feature for a future release. Something like a "aFixedDisplayLength" boolean or similar.

All comments, advices, suggestions of any sort are welcome.

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    I think the best way of doing this would be to create a plug-in that would hook into fnDrawCallback - it could then adjust the height of the table by manipulating elements (adding, removing etc) as required. I think this would need to be done on every draw, not just a length change since row heights can vary between pages.

    I'm sure there would be interest from others if you were to create such software :-). Its not something I think I would add to DataTables core, simply because I'm being very strict about features in the core that could be provided with plug-ins, in order to keep the file size as small as possible.

    Allan
  • mfreremfrere Posts: 4Questions: 0Answers: 0
    Thanks for the answer Allan. I'm working on a pretty big project at the moment and there's not a lot of developers on it at the moment, so this is not going to be my highest priority (many low level features still to be written). However, I'll be happy to post the solution when I have one.
    Michael
This discussion has been closed.