View Full Version : ComboBox selected entry at the top

27 Apr 2010, 1:56 AM

I've got a little problem with the ComboBox.
I want the selected entry of the ComboBox to be at the top.

For better understanding I've attached two images.

The image combo1.png is the actual state of the ComboBox.
And the image combo2.png is the state of the ComboBox, I want to get.

Thanks eztam!

27 Apr 2010, 3:09 AM
* Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
* The store must be loaded and the list expanded for this function to work, otherwise use setValue.
* @param {Number} index The zero-based index of the list item to select
* @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
* selected item if it is not currently in view (defaults to true)
select : function(index, scrollIntoView){
this.selectedIndex = index;
if(scrollIntoView !== false){
var el = this.view.getNode(index);
this.innerList.scrollChildIntoView(el, false);


kind regards,

29 Apr 2010, 11:10 PM

My solution:

scrollIntoView: function(container, hscroll) {
var c = Ext.getDom(container) || Ext.getBody().dom,
el = this.dom,
o = this.getOffsetsTo(c),
l = o[0] + c.scrollLeft,
t = o[1] + c.scrollTop,
b = t + el.offsetHeight,
r = l + el.offsetWidth,
ch = c.clientHeight,
ct = parseInt(c.scrollTop, 10),
cl = parseInt(c.scrollLeft, 10),
cb = ct + ch,
cr = cl + c.clientWidth;

c.scrollTop = t;

if(hscroll !== false){
if(el.offsetWidth > c.clientWidth || l < cl){
c.scrollLeft = l;
}else if(r > cr){
c.scrollLeft = r - c.clientWidth;
c.scrollLeft = c.scrollLeft;
return this;

29 Apr 2010, 11:30 PM
you shoot at a bird with a cannon =)

why writing an own method, when the default select-method of a combo already has all you need?

kind regards,