View Full Version : [CLOSED] [#551] Scroll to current Item in ComboBox trigger click

Sep 16, 2014, 7:19 PM
In a combobox setup with


so that all items display in the dropdown. Is it possible to scroll to the currently selected record when the dropdown is triggered.

Something like the grids scrollintoView on the trigger click.

Sep 16, 2014, 7:49 PM
Hi @AaronDev,

Welcome to the Ext.NET forums!

Honestly, I am a bit surprised why there is no such a setting to scroll to the selected item (also I would expect it to be true by default).

As a solution, I can suggest to listen to the Expand event and scroll.


<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
if (!X.IsAjaxRequest)
object[] data = new object[50];

for (int i = 0; i < 50; i++)
data[i] = new object[] { i, "Item" + i };

this.ComboBox1.GetStore().DataSource = data;

<!DOCTYPE html>

<head runat="server">
<title>Ext.NET v2 Example</title>

var onExpand = function() {
var me = this,
picker = me.picker,
selected, itemNode;

if (picker.getSelectionModel().hasSelection()) {
selected = picker.getSelectionModel().getSelection()[0];
itemNode = picker.getNode(selected);

if (itemNode) {
picker.listEl.scrollChildIntoView(itemNode, false);
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Store runat="server">
<ext:Model runat="server">
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
<ext:ArrayReader />
<Expand Fn="onExpand" />

Sep 16, 2014, 8:57 PM
Thanks that works perfectly.

Yea, thought the same, but glad it's possible!

Sep 16, 2014, 9:22 PM
This seems like a feature(?) we need to build into the ComboBox.

I will discuss with @daniil and maybe we can implement this as the default functionality in the next release.

Sep 17, 2014, 5:24 AM
I was also thinking about that. It should not be a problem to implement it.

Geoffrey, do you think we should change the existing behavior? I mean should it scroll by default? We can make it configurable, at least. True or false by default? Please share your opinion.

Sep 17, 2014, 6:07 AM
Here's a challenge... I think I'd prefer if the selected Item was scrolled to the middle of the visible list.

The following two images demonstrate. The first shows the existing functionality, with the onExpand fix:


The second image shows the proposed scroll position:


If "scroll to the middle" requires too much bloat, then "scroll to the item" is good enough.

I don't think there should be a config for this functionality, it should have been working this way to begin with. I'd consider the existing (non-scrolling) functionality to be a defect.

Hope this helps.

Sep 18, 2014, 8:35 AM
Agree, it looks a defect. Also, center alignment appears to be best.

Created an Issue:

It has been fixed (with center alignment) in the SVN trunk in the revision 5981. It will go to the v2.5.1 release.

Thank you for bringing the problem to us.

Sep 18, 2014, 1:30 PM
I've just tested with Ext.NET v3 (ExtJS 5). The scrollbar position is preserved (maybe, restored) on trigger clicks. Do we really need to change that behavior in Ext.NET v3? I think it might be expected by user. Though, it is a slight difference in the behavior between v2 and v3. Seems, no problem with that.

Please share your opinion.

Sep 18, 2014, 1:48 PM
Either would have suited my needs and maybe even the v3 behaviour would be preferable. Sometimes the users can use the dropdown as a reference without actually selecting an item and in that case it's better to stay were they were the last time they scrolled.

Sep 18, 2014, 3:30 PM
Thank you for sharing your opinion. I tend to agree with you.

Sep 18, 2014, 3:32 PM
Yes, agreed. Maintaining scroll position would be the best solution.

Sep 19, 2014, 11:20 AM
Maintaining scroll position has been implemented in the SVN trunk, the revision #5986. It will go to the v2.5.3 release.