1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    17
    Vote Rating
    0
    milo08 is on a distinguished road

      0  

    Question Scroll to an selected Item in a List

    Scroll to an selected Item in a List


    Hi @ll,

    i searched in the Forum and in the Api Documentation but i couldn`t find a solution, and i think the questions/solution is quite simple, maybe i searched for the false cue. X) SenchaTouch (Version 0.93)

    I have a "List" like the List in the examples, with a searchfield.
    If i write a word in this searchbox, i get the listIndex and i select
    this word in the list. That works.

    But i can´t scroll to this item in the list. ;(

    Some code:

    Code:
    var searchbox = new Ext.form.SearchField({
                placeholder: 'Search',
                enableKeyEvents : true,
                style: 'width: 180px; background-color:#fff;',
                centered: true,
                store: wordList,
                cls: 'usearch',
                 listeners: {
                    keyup: {
                           fn: function(dataview)
                           {
                                   var value = searchbox.getValue();
    
                                   if (value.length > 0)
                                   {
                                       var listId = wordList.find('word',value);
    
                                        browseList.select(listId);
    
                                     
                                }
                           },
                                scope: this,
                                buffer: 400}
                } // listener
            });
    I can scroll with

    "browseList.scroller.scrollTo({x:0,y:0}, true);"

    to the top, but i need the x and y coordinates from the selected item. Futhermore i test to focus this row and
    to scroll in the View but it doesn`t works.

    greetz and thx

    milo

  2. #2
    Sencha User
    Join Date
    Aug 2010
    Posts
    17
    Vote Rating
    0
    milo08 is on a distinguished road

      0  

    Default


    I solved this Problem and I made example on the List, for people with the same problem:

    The important code:

    Code:
    var suchFeld = new Ext.form.SearchField({
                placeholder: 'Search',
                enableKeyEvents : true,
                style: 'width: 180px; background-color:#fff;',
                centered: true,
                store: groupingBase.store,
                cls: 'usearch',
                  listeners: {
                    keyup: {
                           fn: function(dataview)
                           {
                              
                               var value = suchFeld.getValue();
                                
                                
                                   if (value.length > 0)
                                   {
                                       //its important to set the list entry coordinate at the beginnig from the list   
                                    browseList.scroller.scrollTo({x:0,y:0}, false);
                                    
                                    
                                       var listId = groupingBase.store.find('firstName',value);
                                        
                                    //select the list entry    
                                       browseList.select(listId);
                                    
                                    //get the html div element
                                    var ehtml = browseList.getNode(listId);
                                    
                                    //build a new element
                                    var el = Ext.get(ehtml);
                                    
                                    //get the coordinate in the list from this element 
                                    //extraxct list height from y-coordinate to get the absolute position
                                    
                                    var ykor =    el.getY()-browseList.getHeight();
                                
                                    var xkor =  el.getX();
                                    
                                    //alert(ykor);
                                    
                                    //scroll to the coordinate
                                    browseList.scroller.scrollTo({x:xkor,y:ykor}, true);
                                    
                                }  
                               
                        
                           },
                                scope: this,
                                buffer: 400}
                } // listener
            });
    Full code list example with search on firstName:



    Code:
    Ext.setup({
        tabletStartupScreen: 'tablet_startup.png',
        phoneStartupScreen: 'phone_startup.png',
        icon: 'icon.png',
        glossOnIcon: false,
        onReady : function() {
            Ext.regModel('Contact', {
                fields: ['firstName', 'lastName']
            });
            
            
    
            var groupingBase = {
                tpl: '<tpl for="."><div  class="contact"><strong>{firstName}</strong>  {lastName}</div></tpl>',
                itemSelector: 'div.contact',
    
                singleSelect: true,
                grouped: true,
                indexBar: true,
                
    
                disclosure: {
                    scope: 'test',
                    handler: function(record, btn, index) {
                        alert('Disclose more info for ' + record.get('firstName'));
                    }
                },
                
                
    
                store: new Ext.data.Store({
                    model: 'Contact',
                    sorters: 'firstName',
    
                    getGroupString : function(record) {
                        return record.get('firstName')[0];
                    },
    
                    data: [
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Ape', lastName: 'Evilias'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Ape', lastName: 'Evilias'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Ape', lastName: 'Evilias'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Ape', lastName: 'Evilias'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Tommy', lastName: 'Maintz'},
                        {firstName: 'Ed', lastName: 'Spencer'},
                        {firstName: 'Jamie', lastName: 'Avins'},
                        {firstName: 'Aaron', lastName: 'Conran'},
                        {firstName: 'Dave', lastName: 'Kaneda'},
                        {firstName: 'Michael', lastName: 'Mullany'},
                        {firstName: 'Abraham', lastName: 'Elias'},
                        {firstName: 'Jay', lastName: 'Robinson'},
                        {firstName: 'Zed', lastName: 'Zacharias'}
                    ],
                    
          
                    
                })
            };
            
        
             var suchFeld = new Ext.form.SearchField({
                placeholder: 'Search',
                enableKeyEvents : true,
                style: 'width: 180px; background-color:#fff;',
                centered: true,
                store: groupingBase.store,
                cls: 'usearch',
                  listeners: {
                    keyup: {
                           fn: function(dataview)
                           {
                              
                               var value = suchFeld.getValue();
                                
                                
                                   if (value.length > 0)
                                   {
                                       
                                    browseList.scroller.scrollTo({x:0,y:0}, false);
                                    
                                       var listId = groupingBase.store.find('firstName',value);
                                        
                                       browseList.select(listId);
                                    
                                    var ehtml = browseList.getNode(listId);
                                    var el = Ext.get(ehtml);
                                    
                                    var ykor =  el.getY()-browseList.getHeight();
                                    var xkor =  el.getX();
                                    
                                    //alert(ykor);
                                    
                                    browseList.scroller.scrollTo({x:xkor,y:ykor}, true);
                                    
                                }  
                               
                        
                           },
                                scope: this,
                                buffer: 400}
                } // listener
            });
        
          var browseToolbar = new Ext.Toolbar({
                xtype: 'toolbar',
                dock: 'top',
                ui: 'light',
                items: suchFeld
    
            });
    
            if (!Ext.platform.isPhone) {
                var browseList = new Ext.List(Ext.apply(groupingBase, {
                    dockedItems: [ browseToolbar ],
                    floating: true,
                    width: 350,
                    height: 370,
                    centered: true,
                    modal: true,
                    hideOnMaskTap: false
                })).show();
            }
            else {
                var browseList = new Ext.List(Ext.apply(groupingBase, {
                    dockedItems: [ browseToolbar ],
                    fullscreen: true
                }));
            }
        }
    });
    greetz milo

  3. #3
    Ext User
    Join Date
    Aug 2010
    Posts
    7
    Vote Rating
    0
    mithun2005 is on a distinguished road

      0  

    Default


    Hey thanks milo !!! A brilliant post indeed !!! I have a question

    How do you show the selected item at the top of the list?

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,925
    Vote Rating
    632
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The list is backed by a store, so you would need to move that record to be the first item in the store.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Ext User
    Join Date
    Aug 2010
    Posts
    7
    Vote Rating
    0
    mithun2005 is on a distinguished road

      0  

    Lightbulb


    Quote Originally Posted by evant View Post
    The list is backed by a store, so you would need to move that record to be the first item in the store.

    Evant : In the list of items how do I move an item to the first in the store?

    Is that I need to create a subarray of the set of items and give that as the new store?

    Ex: Say I have a list of these items

    data: [
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Ape', lastName: 'Evilias'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Ape', lastName: 'Evilias'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Ape', lastName: 'Evilias'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Ape', lastName: 'Evilias'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Tommy', lastName: 'Maintz'},
    {firstName: 'Ed', lastName: 'Spencer'},
    {firstName: 'Jamie', lastName: 'Avins'},
    {firstName: 'Aaron', lastName: 'Conran'},
    {firstName: 'Dave', lastName: 'Kaneda'},
    {firstName: 'Michael', lastName: 'Mullany'},
    {firstName: 'Abraham', lastName: 'Elias'},
    {firstName: 'Jay', lastName: 'Robinson'},
    {firstName: 'Zed', lastName: 'Zacharias'}
    ],

    and I want to display "Abraham Elias " at the top of the list, what is the approach that needs to be taken?

    Can you please shed some light on this?

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,925
    Vote Rating
    632
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Store has an insert method, so just insert it at the first position.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User interfasys's Avatar
    Join Date
    Mar 2011
    Location
    UK & Switzerland
    Posts
    125
    Vote Rating
    1
    interfasys is on a distinguished road

      0  

    Default


    @milo08 - Thank you for this. This should make it into the core package as an option when updating a store.

  8. #8
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    61
    Vote Rating
    0
    dishwashwebdesign is on a distinguished road

      0  

    Default


    looks just what i needed
    did you get that piece of code working in sencha touch 2 as well?
    looks like the list element doesnt have the scroller functionality...

    dont worry, just took out some code of senchas sdk (sdk/src/dataview/List.jssdk/src/dataview/List.js):
    Code:
    var store = mylist.getStore();
                var groups = store.getGroups();
                var ln = groups.length;
                var key = rec.get('name').substr(0,1).toLowerCase();
                for (i = 0; i < ln; i++) {
                    group = groups[i];
                    id = group.name.toLowerCase();
                    if (id == key || id > key) {
                        closest = group;
                        break;
                    }
                    else {
                        closest = group;
                    }
                }
                var scroller = mylist.getScrollable().getScroller();
                var item = mylist.container.getViewItems()[store.indexOf(closest.children[0])];
                var containerSize = scroller.getContainerSize().y,
                    size = scroller.getSize().y,
                    maxOffset = size - containerSize,
                    offset = (item.offsetTop > maxOffset) ? maxOffset : item.offsetTop;
                    scroller.scrollTo(0, offset);
    this did the job for me

  9. #9
    Sencha User
    Join Date
    May 2010
    Location
    Jakarta - Indonesia
    Posts
    169
    Vote Rating
    0
    yagi is on a distinguished road

      0  

    Default


    Thanks,, It's what I need
    Berusaha dan Berdoa

Similar Threads

  1. x-item-selected class on list doen't work
    By wakatanka in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 1 Sep 2010, 8:56 AM
  2. disabling currently selected item in a list
    By cabennett85 in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 8 Aug 2010, 9:01 PM
  3. Replies: 5
    Last Post: 26 Jun 2009, 2:42 AM
  4. Replies: 3
    Last Post: 16 Feb 2009, 4:44 AM
  5. Replies: 1
    Last Post: 24 Sep 2008, 8:07 AM

Thread Participants: 5