const $table = $('#t1'); // Function to calculate and apply the perfect height function updateTableHeight() { // baseHeight uses the window inner height to stay stable const availableHeight = window.innerHeight - 170; // Ensure we don't drop below a minimum height (e.g., 300px) const finalHeight = Math.max(availableHeight, 300); // Bootstrap Table natively supports setting just the height without rewriting all options $table.bootstrapTable('resetView', { height: finalHeight }); } // Debounce function to prevent performance issues during active resizing function debounce(func, wait) { let timeout; return function(...args) { clearTimeout(timeout); timeout = setTimeout(() => func.apply(this, args), wait); }; } // Initialization when DOM is fully ready and Bootstrap Table is loaded $(function () { // Small timeout to let Bootstrap Table finalize its internal rendering first setTimeout(updateTableHeight, 200); }); // Throttled listener for window resize window.addEventListener('resize', debounce(updateTableHeight, 150));