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

Splitter height based on content

7 Answers 296 Views
Splitter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Guillaume
Top achievements
Rank 1
Guillaume asked on 05 Aug 2011, 09:05 PM
Hi,
I have a simple layout : a menu (Telerik) and below it a splitter which contains two horizontal pane. The first pane contains a treeview (Telerik) and the second a form.
By default the splitter has a height of 300px provided by the css. When expanding the treeview nodes, the height gets bigger than 300px (but less than the screen height) and i have a vertical scrollbar appearing inside the splitter. I've tried changing the splitter height so that it's not fixed and gets the content's height but i don't seem to find a good solution.
Anyone knows how to do this ?

Thanks,
Guillaume

7 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 08 Aug 2011, 11:39 AM
Hi Guillaume,

There is no easy way for the splitter to resize depending on its contents. Wouldn't a full-screen splitter work in your scenario?

Regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Levi
Top achievements
Rank 1
answered on 04 Oct 2011, 06:59 PM
Why not? When I use firebug to remove the "height: 300px" from each of the t-pane's style attributes, the splitter conforms to the height of my ajax loaded content.

My problems is I can't get the splitter to not render the height attribute inside the style elements of the panes. Setting the HtmlAttributes property for the panes doesn't do anything. I did notice that when I set the height in the HtmlAttributes of the Splitter itself, that value is rendered in the height of the style tag for each of the panes. Yaay! I should be able to set the height to auto and bingo! No.. doing that, or height 100% deflates the entire splitter. Further investigation revealed that either of these two settings actually render the style of the panel to a height: 0. Why could it just.. not add a height property to the style of the panels? Doing this in FireBug appears to fix the issue all together.
0
Levi
Top achievements
Rank 1
answered on 04 Oct 2011, 07:05 PM
This is a step in the right direction, but there seems to still be overlapping of content underneath any expanded content in the splitter. I think it has something to do with the panes being absolutely positioned.

$(document).ready(function () {
    $(".t-pane").css("height", "auto");
});
0
Dimo
Telerik team
answered on 05 Oct 2011, 08:12 AM
Hello,

The Splitter has not been designed to support automatic-height panes, because one can use plain styled <div>s for that (and no JS is required). In theory, you can force panes to expand as much as needed by setting a height: auto !important; style, but this will lead to unwanted side effects, such as misplaced splitbars. You will also need position:static !important;

The discussed behavior may be achievable, but only in specific scenarios.

Best wishes,
Dimo
the Telerik team
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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Varghese
Top achievements
Rank 1
answered on 22 Oct 2011, 02:43 PM
I also noticed the height problem in my application. I have three containers and the splitter control is inside them. I can't change the height of the splitter externally through the HtmlAttribute.

The solution seems to be manipulating the DOM via JQuery.
0
Alex
Top achievements
Rank 1
answered on 16 May 2012, 02:30 PM
You're absolutely right Varghese.  I was able to create a solution with the following javascript:

//hook this into your splitter OnLoad event
function DetailSplitter_OnLoad(e) {
    //$('#' + e.target.id) could be used to manipulate the splitter as well
    AdjustDetailSplitterHeight();
}
 
function AdjustMySplitterHeight() {
    //adjust the splitter
    var splitter = $("#MySplitter");
    var adjustContstant = 60; //change this to suit your particular page.
    var newSplitterHeight = $(window).height() - splitter.position().top - adjustContstant;
    splitter.css("height", newSplitterHeight + "px");
 
    //adjust anything else you want here
     
    splitter.resize();
}
 
//used to debounce
var delay = (function () {
    var timer = 0;
    return function (callback, ms) {
        clearTimeout(timer);
        timer = setTimeout(callback, ms);
    };
})();
 
//browser window resize support
//MUST BE RUN AFTER MARKUP
if ($("#MySplitter").length) {
    $(window).resize(function () {
        delay(function () {
            var splitter = $("#MySplitter");
            if (splitter.length) {
                AdjustDetailSplitterHeight("#MySplitter");
            }
        }, 200);
    });   
}


0
Shawn
Top achievements
Rank 2
answered on 01 Jul 2012, 06:32 AM
Thanks this worked for me.
Tags
Splitter
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Levi
Top achievements
Rank 1
Dimo
Telerik team
Varghese
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Shawn
Top achievements
Rank 2
Share this question
or