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

Scroll listbox to the bottom?

2 Answers 386 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Timo
Top achievements
Rank 1
Timo asked on 27 Dec 2019, 08:25 AM
It there a way to sroll a listbox to the bottom programmatically? I just want to scroll the box to the bottom, without selecting any element on the list.

2 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 27 Dec 2019, 11:29 AM

Hi Timo,

The Kendo UI ListBox widget is compiled down to simple HTML. Therefore, you could access the height of the list holding the items and programmatically scroll down the parent element of this list. Here is an example:

var height = $(".k-listbox ul.k-list:eq(0)").height();
$(".k-listbox ul.k-list:eq(0)").closest(".k-list-scroller").scrollTop(height);

I hope you find this helpful.

 

Regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
hassan
Top achievements
Rank 1
Iron
answered on 31 Aug 2023, 09:32 AM | edited on 31 Aug 2023, 09:34 AM

 

Hi below snippet from one of my active project and i was struggling to get this done  as well. finally managed to sort it out. below script works perfectly. 

 

var objlistbox = $("#listboxone").data("kendoListBox");

//Scroll to last item in the list

 let uid = objlistbox .dataItems()[12].uid;

 let item = objlistbox .wrapper.find("[data-uid='" + uid+ "']");

 objlistbox .items().each(function (i, element) {
   
     if ($(element).text().toLowerCase().trim() == item.text().toLowerCase().trim()) {
         //console.log('matching found');
         objlistbox .select($(element));
         $(".k-list-content").scrollTop($(element).position().top);
         return;
     };

 
Nikolay
Telerik team
commented on 04 Sep 2023, 07:11 AM

Hi Hassan,

Thank you for sharing this with the community. It surely will help others facing the same scenario.

Regards,

Nikolay

Tags
ListBox
Asked by
Timo
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
hassan
Top achievements
Rank 1
Iron
Share this question
or