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?

    Thanks

    Michael
  2. Yana
    Admin
    Yana avatar
    4554 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";
        }
    </script>

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

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

    Best regards,
    Yana
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. SlavaTT
    SlavaTT avatar
    2 posts
    Member since:
    May 2007

    Posted 25 May 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.

     

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    834 posts

    Posted 30 May Link to this post

    Hello Slava,

    _groupElement
    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";

    Regards,
    Ivan Danchev
    Telerik
    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