function resizeGrid() { //Define Elements Needed var header = $("#header-content"); var content = $("#main-content"); var grid = $("#grid"); //Other variables var minimumAcceptableGridHeight = 250; //This is roughly 5 rows var otherElementsHeight = 0; //Get Window Height var windowHeight = $(window).innerHeight(); //Get Header Height if its existing var hasHeader = header.length; var headerHeight = hasHeader ? header.outerHeight(true) : 0; //Get the Grid Element and Areas Inside It var contentArea = grid.find(".k-grid-content"); //This is the content Where Grid is located var otherGridElements = grid.children().not(".k-grid-content"); //This is anything ather than the Grid iteslf like header, commands, etc console.debug(otherGridElements); //Calcualte all Grid elements height otherGridElements.each(function () { otherElementsHeight += $(this).outerHeight(true); }); //Get other elements same level as Grid var parentDiv = grid.parent("div"); var hasMainContent = parentDiv.length; if (hasMainContent) { var otherSiblingElements = content.children() .not("#grid") .not("script"); //Calculate all Sibling element height otherSiblingElements.each(function () { otherElementsHeight += $(this).outerHeight(true); }); } //Padding you want to apply below your page var bottomPadding = 10; //Check if Calculated height is below threshold var calculatedHeight = windowHeight - headerHeight - otherElementsHeight - bottomPadding; var finalHeight = calculatedHeight < minimumAcceptableGridHeight ? minimumAcceptableGridHeight : calculatedHeight; //Apply the height for the content area contentArea.height(finalHeight); } $(window).resize(function () { resizeGrid(); }); $("#grid").kendoGrid({ dataSource: { type: "odata", transport: { read: "http://demos.kendoui.com/service/Northwind.svc/Orders" }, schema: { model: { fields: { OrderID: { type: "number" }, ShipName: { type: "string" }, ShipCountry: { type: "string" }, Freight: { type: "decimal" } } } }, pageSize: 10, serverPaging: true, serverFiltering: true, serverSorting: true }, filterable: true, sortable: true, pageable: true, dataBound: resizeGrid, columns: [{ field: "OrderID", filterable: false }, "ShipName", "ShipCountry", "Freight" ] });
<!--Full article at http://wp.me/p4JH2A-I3 --> <div id="header-content">This is a header, place where you usually add your menu</div> <div id="main-content"> <h1>Top Section</h1> <div id="grid"></div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ultricies sem ut metus elementum, nec cursus nulla dictum. Nam facilisis neque eu sodales ultricies. Pellentesque faucibus justo eget urna viverra, eget maximus lectus varius. Vivamus consectetur tellus at pulvinar finibus. Donec ipsum ligula, placerat in tincidunt in, sollicitudin sed ante. Maecenas eu urna elementum, porta sapien at, ornare lectus. Sed interdum magna at lectus aliquam imperdiet. Mauris ultrices erat a tincidunt pellentesque. Pellentesque sit amet lacinia nisi. Morbi sollicitudin, sapien congue eleifend rhoncus, sem est iaculis arcu, nec mattis turpis urna ac nisl. Duis eleifend vehicula convallis. Fusce est neque, efficitur vel rhoncus vitae, condimentum non risus. Ut consequat egestas dui, in condimentum arcu auctor ac. Morbi volutpat facilisis velit, quis faucibus dui dictum at. Etiam ullamcorper libero blandit blandit accumsan. Fusce sagittis justo nisl, et semper ipsum aliquam in.</p> </div>