RadListBox Height

4 posts, 0 answers
  1. Michael Landy
    Michael Landy avatar
    15 posts
    Member since:
    Dec 2009

    Posted 09 Mar 2010 Link to this post

    I would like to set the height of the listbox to show 5 rows of data.  The rows are simple text entries using RadListBoxItem.  In order to set the height, it seems like I would have to calculate the height of one item and multiple that by the number of rows that I want to show.  Then, set the height of the listbox to this value.

    The "height" property for the RadListItem is blank before adding to a listbox, after adding to a listbox, and after adding to an update panel on the page.  I kind of figured this was the case given that the style sheet may cause the size to change.

    So, how should I set the height of a listbox assuming I want to show 5 items at a time?  Do I calculate it on the server side using best guess at the row size?  How well does that work for cross browser implementations?  Do I calculate it on the client side in javascript?

    What would be the best approach to this?


  2. Yana
    Yana avatar
    5013 posts

    Posted 10 Mar 2010 Link to this post

    Hello Michael Landy,

    I suggest you subscribe to OnClientLoad event of the listbox and calculate the height in its handler:

    <script type="text/javascript">
        function listBoxLoad(sender, args) {
            var elementHeight = $telerik.getSize(sender.get_items().getItem(0).get_element()).height;
            sender._groupElement.style.height = (elementHeight*5) + "px";

    also you should add the following css styles to your page:

    <style type="text/css">
        .rlbGroup, .rlbList { overflow: auto !important; }

    Best regards,
    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.
  3. Slava
    Slava avatar
    6 posts
    Member since:
    May 2007

    Posted 25 May 2016 in reply to Yana Link to this post

    Yana is great, boys.

    sender._groupElement has appeared to be important undocumented thing here.

    I tried get_element(), get_childElement() and neigher worked well.


  4. Ivan Danchev
    Ivan Danchev avatar
    2129 posts

    Posted 30 May 2016 Link to this post

    Hello Slava,

    is a private property, that is why it is not mentioned in the documentation. In the code snippet posted by Yana it can be replaced by the public get_childListElement() client-side method:
    sender.get_childListElement().style.height = (elementHeight * 5) + "px";

    Ivan Danchev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top