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

Rad list box scrollintoview show item in first

6 Answers 257 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
vinoth sansar
Top achievements
Rank 2
vinoth sansar asked on 17 Nov 2011, 11:14 AM
Dear telerik  team,

                  In Radlistbox contains number of items, Am finding using textbox. using tem.scrollIntoView am achieving scroll the position to change. I need to show as first in the item. Is any script to show item as top. Below coding is am using.
ASPX
--------
<table border="0" cellpadding="0" cellspacing="0">
             <tr>
        <td>
                   <telerik:RadTextBox ID="txtSelectPgm" TabIndex="1" runat="server" Width="295px" onpaste="filterListBoxPaste()" ClientEvents-OnFocus="focusto" ClientEvents-OnKeyPress="filterListBox" SelectionOnFocus="SelectAll">
                   </telerik:RadTextBox >
                          </td>
               </tr>
         <tr>
             <td>
            <telerik:RadListBox ID="lstSelectPgm" TabIndex="4" OnClientSelectedIndexChanged="GetProgramName"
             runat="server"
                   Width="300px"
                Height="390px" AutoPostBack="false">
                   </telerik:RadListBox>
          </td>
          </tr>
      </table>
 
JS:
----
 
function filterListBox(sender, e) {
    var SelectPrgm;
    var list = $find("ctl00_Content_lstSelectPgm");
    SelectPrgm = $find("ctl00_Content_txtSelectPgm");
    if (searchText == "")
        searchText = e.get_keyCharacter();
    else
        searchText = SelectPrgm.get_value() + e.get_keyCharacter();
    var items = list.get_items();   
    for (var i = 0; i < items.get_count(); i++) {
        var item = items.getItem(i);       
        if (item.get_text().toLowerCase().startsWith(searchText.toLowerCase())) {
            item.select();
            item.ensureVisible();
            item.scrollIntoView;           
            break;
        }
    }
    SelectPrgm.set_textBoxValue(searchText);
    setTimeout(filterText, 10);
}

   

6 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 22 Nov 2011, 12:23 PM
Hello Vinoth,

Please review the attached project. I changed your code to work as expected.

Kind regards,
Peter Filipov
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
vinoth sansar
Top achievements
Rank 2
answered on 24 Nov 2011, 08:19 AM
Thanks Peter Filipo
0
vinoth sansar
Top achievements
Rank 2
answered on 29 Nov 2011, 12:01 PM
Hello Peter,

         I cheked your project, But its not working as iam expected.
pls check the image in attachment. I dont know its possible or not.
0
Peter Filipov
Telerik team
answered on 02 Dec 2011, 09:34 AM
Hello Vinoth,

ScrollIntoView method acts like you want only if the item is not into the visible area of the RadListBox. When the item is into the visible area, the method does not scroll.

Regards,
Peter Filipov
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
vinoth sansar
Top achievements
Rank 2
answered on 02 Dec 2011, 11:35 AM
hello Peter.

   Thank you so much for your response.
    Is there anyway to scroll, When the item is into the visible area.

thanks,
vinoth


0
Peter Filipov
Telerik team
answered on 07 Dec 2011, 11:09 AM
Hello Vinoth,

Unfortunately the described scenario is not possible to be achieved.

Greetings,
Peter Filipov
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
Tags
ListBox
Asked by
vinoth sansar
Top achievements
Rank 2
Answers by
Peter Filipov
Telerik team
vinoth sansar
Top achievements
Rank 2
Share this question
or