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

RadCombo Scroll Position

2 Answers 164 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 18 Oct 2012, 01:42 PM
Hi,

I have a radcombobox with checkboxes and am using multiselect.  I am using the server side on click event which of course is causing a postback.  With this in mind is it possible to maintain the scroll position in the rad combo box. 
For example,  if I check the 54th item in the list it then returns me back to the top of the list.  I would like it to return to the item that I checked.

Thank you for your help.
Tracy

2 Answers, 1 is accepted

Sort by
0
Accepted
Kalina
Telerik team
answered on 22 Oct 2012, 01:09 PM
Hello Tracy,

I am afraid that updating the scroll position to the last checked item after postback is not a supported scenario.

You can optionally try implementing this behaviour with custom code.
The last checked item index can be stored in a HiddenField at OnClientItemChecked event handler function.
Then at OnClientDropDownOpened event you can “scroll” to this item explicitly.
<script type="text/javascript">
 
var hiddenField;
var indexToHighLight;
 
function pageLoad() {
    hiddenField = document.getElementById("<%=lastCheckedIndex.ClientID %>");
    indexToHighLight = hiddenField.value;
}
 
function OnClientDropDownOpening(sender, eventArgs) {
    var items = sender.get_items();
 
    if (indexToHighLight) {
        items.getItem(indexToHighLight).highlight();
        items.getItem(indexToHighLight).scrollOnTop();
    }
}
 
function OnClientItemChecked(sender, eventArgs) {
    hiddenField.value = eventArgs.get_item().get_index();
    indexToHighLight = eventArgs.get_item().get_index()
}
 
 
</script>


<telerik:RadComboBox ID="RadComboBox2" runat="server"
    OnClientDropDownOpened="OnClientDropDownOpening"
    OnClientItemChecked="OnClientItemChecked"
    AutoPostBack="true"
    CheckBoxes="true"
    EnableCheckAllItemsCheckBox="true"
    Height="70px">
    <Items>
        <telerik:RadComboBoxItem Text="test1" Value="1" />
        <telerik:RadComboBoxItem Text="test2" Value="2" />
        <telerik:RadComboBoxItem Text="test3" Value="3" />
        <telerik:RadComboBoxItem Text="test4" Value="4" />
        <telerik:RadComboBoxItem Text="test5" Value="5" />
        <telerik:RadComboBoxItem Text="test6" Value="6" />
        <telerik:RadComboBoxItem Text="test7" Value="7" />
        <telerik:RadComboBoxItem Text="test8" Value="8" />
        <telerik:RadComboBoxItem Text="test9" Value="9" />
        <telerik:RadComboBoxItem Text="test10" Value="10" />
        <telerik:RadComboBoxItem Text="test11" Value="11" />
    </Items>
</telerik:RadComboBox>
<asp:HiddenField ID="lastCheckedIndex" runat="server" />

All the best,
Kalina
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Tracy
Top achievements
Rank 1
answered on 22 Oct 2012, 07:04 PM
Hi Kalina,

This worked perfectly.

Thanks for your help.
Tracy
Tags
ComboBox
Asked by
Tracy
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Tracy
Top achievements
Rank 1
Share this question
or