<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1407/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1407/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2011.3.1407/js/kendo.all.min.js"></script>
<!-- Full article at http://wp.me/p4JH2A-Ic -->
<body>
<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>
</body>
JavaScript
function resizeGrid() {
//Check if grid is available
if (!$("#grid").length) {
return;
}
//Initialize some variables
var bottomPadding = 10;
var minimumAcceptableGridHeight = 250;
var combinedElementHeight = bottomPadding;
var windowHeight = $(window).innerHeight();
var grid = $("#grid");
//Calcualte all Grid elements height except the content
var otherGridElements = grid.children().not(".k-grid-content"); //This is anything other than the Grid iteslf like header, commands, etc
otherGridElements.each(function () {
combinedElementHeight += $(this).outerHeight(true);
});
//Lets start from the Grid
var currentElement = grid;
//Lets loop until it reaches the topmost element the <Body>
while (!currentElement.is("body")) {
//The parent of the element
var currentParentElement = currentElement.parent();
//Get same level elements apart from the current element
var currentElementSiblings = currentParentElement.children()
.not(currentElement)
.not("script");
//Combine all the heights of those elements
currentElementSiblings.each(function () {
combinedElementHeight += $(this).outerHeight(true);
console.debug($(this));
console.debug($(this).outerHeight(true));
});
//Set the current element to the the Parent.
currentElement = currentParentElement;
}
//Calculate the final height
combinedElementHeight = windowHeight - combinedElementHeight;
var finalHeight = combinedElementHeight < minimumAcceptableGridHeight ? minimumAcceptableGridHeight : combinedElementHeight;
//Apply the height for the content area
var contentArea = grid.find(".k-grid-content");
contentArea.height(finalHeight);
}
$(window).resize(function () {
resizeGrid();
});
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.