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

Setting ComboBox scroll position

3 Answers 134 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 01 Dec 2010, 01:52 PM
Hi,

I need the ComboBox to show the first item in the list when clicked, rather than automatically scrolling down to the first selected item.

How do I do this?

Thanks,

Rob

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Dec 2010, 08:02 AM
Hello Robert,

Try the following code snippet to achieve this.

Java Script:
<script type="text/javascript">
    var firstItem;
    function OnClientDropDownOpened(sender, args) {
        firstItem = sender.get_items().getItem(0);
        setTimeout("firstItem.scrollIntoView();", 500);
    }
</script>

Thanks,
Princy.
0
Kalina
Telerik team
answered on 08 Dec 2010, 06:20 AM
Hello Robert,

Please try handling the OnClientDropDownOpening of the RadComboBox in this way:

<script type="text/javascript">
 
    function onClientDropDownOpening(sender, eventArgs) {
     
        var highlightedItem = sender.get_highlightedItem();
      
        if (highlightedItem != null)
            highlightedItem.unHighlight();
             
        if(sender.get_items().getItem(0) != null)
            sender.get_items().getItem(0).highlight();
        
    }
</script>


Best wishes,
Kalina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Robert
Top achievements
Rank 1
answered on 08 Dec 2010, 09:24 AM
Thanks Princy, Kalina.

Princy's answer worked for me, although I didn't need to use setTimout(), I just called sender.get_items().getItem(0).scrollIntoView() from within OnClientDropDownOpened() and it worked fine.
Tags
ComboBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kalina
Telerik team
Robert
Top achievements
Rank 1
Share this question
or