Setting table minimum height on search collapse

Setting table minimum height on search collapse

RedfishRedfish Posts: 7Questions: 3Answers: 0

Still new to data tables. All is working but when I apply a search the number of rows returned collapses as expected and the container shrinks accordingly. This creates an issue with some custom menus I have added via a row call back. So I would like to see about setting a minimum height of the table container so even if 2 rows of data were returned the size of the container was say 5 rows high to accommodate the menus I have added. Basically they pop up but since the container is only 2 rows high, you can't see/use the menu.

I have added min-height: 400px; for example to the div.dataTables_scrollBody css, however this made the correct size, but made the 2 returned rows large enough to fill that. So how can I insert a "blank row" if need be to maintain the correct minimum size of the container. Hope that makes sense. Thanks.

Answers

  • colincolin Posts: 15,158Questions: 1Answers: 2,587

    Hi @Redfish ,

    This example here may give an option. It keeps the number of rows consistent. Otherwise, you'll need to put the table into a container, and use CSS to give it a fixed size.

    Cheers,

    Colin

  • RedfishRedfish Posts: 7Questions: 3Answers: 0

    Well the ideal was to use the scrollY in the table initialization. That locked things where they needed to be, however if folks had smaller window sizes then things got a little funky. So I used this to dynamically set the scrollY on load. I chose not to put this in a resize event as it seemed costly for what we needed.

                'scrollY' : function () {
                    var winHeight = window.outerHeight;
                    if (winHeight <= 907) {
                        return '60vh'
                        } else if (winHeight >= 908) {
                        return '67vh'
    
This discussion has been closed.