View Full Version : [FIXED] DataView.select() function no longer works in 2.1.0-rc2

25 Oct 2012, 4:58 PM
I used to have a horizontal scrolling list in It worked. Then in the 2.1 betas it got broken. In the 2.1.0-rc2 I had to switch the list to a dataview in order to be able to scroll horizontally. Now, however, the "select()" function does not select the dataitem.

DataView.select() function has no effect. In "initialize" I specify to select/hilite the first dataview item. It does not hilite it. The dataview has a class assigned to it for the "selected" state - which changes the selected item's background from gray to white.

Here is a working demo (http://www.lesliepere.com/webdev/sencha/hlist-2.1.0-rc2/) using 2.1.0-rc2
1. After initial page load, all items' background is gray. This is incorrect. The "select()" function was called on the first item (ABOUT), yet it is not hilited.
2. Click on the first item (ABOUT). Notice nothing happens, since it is already selected. If an item is selected and you click on it again, nothing will happen. This is proof that it's already selected, yet it's not hilited since the "select()" function doesn't work.
3. Click another item. Notice its background changed to white.
4. Click the first item (ABOUT) again, notice its background changed to white now.
5. When you click an item, the "itemtap" even is handled internally. I don't have anything in the code that handles the "itemtap" event.

Here is the same code (http://www.lesliepere.com/webdev/sencha/hlist- using
Notice as soon as the page loads, the first item (ABOUT) is hilited (using the select() function). This is not possible in 2.1.0-rc2.

DataView code. The select() function is being called from "initialize".

Ext.define('Test.view.HList', {
extend: 'Ext.DataView',
xtype: 'hlist',

config: {
fullscreen: true,
height: 128,
baseCls: 'navbar-list',
selectedCls: 'navbar-list-item-selected',
pressedCls: 'navbar-list-item-pressed',
inline: {
wrap: false
scrollable: {
direction: 'horizontal',
directionLock: true
itemTpl: [
'<div class="navbar-list-items-container">',
'<div style="background: transparent url(\'{img}\') 0 0 no-repeat; width: 96px; height: 96px; border: 1px solid #2c2c2c; float: left; margin-right: 16px;"></div>',
'<div class="navbar-list-item-text">',
'<div class="navbar-list-item-text-title">{title}</div>',
'<div class="navbar-list-item-text-copy">{text}</div>',
store: {
fields: ['title', 'text', 'img'],
data: [
{ title: 'About', text: 'Read something about us and find out why my name is Trinity. Or Jack? Mary? Handsome? Dr. Who?', img: 'resources/images/nav-about.jpg' },
{ title: 'Programs', text: 'We created lots and lots of blurry images. We\'re not really sure why. Maybe because they\'re blurry...?', img: 'resources/images/nav-programs.jpg' },
{ title: 'Locations', text: 'We are here, we are there, we are everywhere! Just check the map if you don\'t believe me.', img: 'resources/images/nav-locations.jpg' },
{ title: 'Blog', text: 'We wrote all sorts of jibberish, full of typos and spelling errors and put them on WordPress.', img: 'resources/images/nav-blog.jpg' },
{ title: 'Contact', text: 'No need to dream of close encounters of the third kind. Call us at Re-Mi-Do-Do-So. Operators are standing by.', img: 'resources/images/nav-contact.jpg' }

initialize: function() {
this.select(0, false, false);

Zipped project (http://www.lesliepere.com/webdev/sencha/hlist-2.1.0-rc2/hlist.zip) (small). In "index.htm" point to y our local sencha installation directory.

26 Oct 2012, 7:40 AM
Looks like when the items are rendered the selection is not looked at.

For now you could do this instead of this.select(...)

this.onAfter('refresh', function() {
this.select(0, false, false);
}, this, { single : true });

26 Oct 2012, 2:24 PM