This is a migrated thread and some comments may be shown as answers.

Resize RadGrid

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fraser
Top achievements
Rank 1
Fraser asked on 24 Jun 2013, 08:54 PM
I need to resize like 5 radgrids using multi page and  a rad tab bar so that they fill the available size in the window. 

I am using scrolling radgrids with static headers, and paging is in no way allowable. Sorting and editing are used on some, either template columns with asp controls or gridbound columns are being used.
 
I am registering a startup script and client script block in the code behind using script manager to handle resize and page load calls of this function

function MGridScrollHeight(control , pBuff) {
    var windowHeight = 0;
    var windowWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE 
        //        alert('non ie');
        windowWidth = window.innerWidth;
        windowHeight = window.innerHeight;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode' 
        //        alert('IE 6+');
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible 
        //        alert('IE 4');
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    var resizeCont = document.getElementById(control);
    var buffer; // BUFFERING
        if (pBuff != undefined) { buffer = pBuff; }
        else { buffer = 30; }
        if ((windowHeight - (resizeCont.offsetTop + resizeCont.offsetParent.offsetTop) - buffer) > 100) {
            resizeCont.style.height = (windowHeight - (resizeCont.offsetTop + resizeCont.offsetParent.offsetTop) - buffer) + 'px';
        }
        else {
            resizeCont.style.height = 100
        }
}

This sort of works in IE and busts all telerik related JS in chrome. I tried resizing divs and then using the onGridCreated event as stated here http://www.telerik.com/help/aspnet-ajax/grid-change-scroll-height-at-runtime.html

However this just plain broke, sender was not passed and the methods of accessing height caused JS on the page to fail without triggering IE's or VS's debugger

If there is a method of being able to resize scrolling radgrids to divs ( I am using obj data sources as company requirement) then I would appreciate a pointer towards it.

2 Answers, 1 is accepted

Sort by
0
Accepted
Galin
Telerik team
answered on 27 Jun 2013, 03:11 PM
Hi Fraser,

I suggest you to set the height of the RadGrid in percents and in this case you should to keep in mind, that  the Control will calculate its dimensions in regards with its container height.

For more information please refer to this code library.

I hope this helps.

Regards,
Galin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Fraser
Top achievements
Rank 1
answered on 27 Jun 2013, 05:56 PM
That code library is super helpful, Thank you.
Tags
Grid
Asked by
Fraser
Top achievements
Rank 1
Answers by
Galin
Telerik team
Fraser
Top achievements
Rank 1
Share this question
or