1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    10
    Vote Rating
    1
    ScottH is on a distinguished road

      0  

    Default List : Scrolling to Selected Item

    List : Scrolling to Selected Item


    I think this the right place to put this.

    Since the relationship between the list and its data store has been changed in 2.1 I added the following to mixin\Selectable.js

    Code:
    selectWithScroll: function (record, suppressEvent) {
           var me = this, index;
            if (me.getDisableSelection()) {
                return;
            }
             index = me.getStore().indexOf(record);
            if (me.xtype == 'list')
                me.doScrollSelect(record, index, suppressEvent);
            else
                me.doSingleSelect(record, suppressEvent);
    },
    doScrollSelect: function (record, index, suppressEvent) {
            var me = this,
                selected = me.selected;
             if (me.getDisableSelection()) {
                return;
            }
            if (me.isSelected(record)) {
                return;
            }
             if (selected.getCount() > 0) { 
               me.deselect(me.getLastSelected(), suppressEvent);
            }
             selected.add(record);
            me.setLastSelected(record);
            me.onItemSelect(record, suppressEvent);
            me.setLastFocused(record);
    
             if (index > 0) {
                var scroller = me.getScrollable().getScroller(),
                    direction = scroller.getDirection(),
                    itemScroll;
                if (direction == 'vertical') {
                    itemScroll = (me.getItemHeight() * index);
                    scroller.scrollTo(0, itemScroll);
                }
                else if (direction == 'horizontal') {
                    itemScroll = (me.getItemWidth() * index);
                    scroller.scrollTo(itemScroll, 0);
                }
            }
             if (!suppressEvent) {
                me.fireSelectionChange([record]);
            }
    },
    
    Calling this instead of .select with a list will select the item and then scroll the list so that the selected item is at the top (unfortunately, without animation).

    Only works for Lists, and the horizontal functionality is theoretical as inline lists aren't up and running in 2.1.

    Please let me know if there is already an existing method of doing this, I was unable to find one prior to putting this in.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,711
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    How did you add that method? Did you just edit the file or create an override?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    10
    Vote Rating
    1
    ScottH is on a distinguished road

      0  

    Default


    I just edited the file, made copies of the existing functions and renamed and modified the copies.

    For my use I wanted something that I could just call from anywhere and not have to be concerned with adding/referencing override functions.

    Animations are a bit of a bummer, spent a little bit of time running down what was going on, but without knowing what you guys are currently working on and with my own time deadlines figured it was best just to go without for now.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,711
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You should not edit any file from the framework or you will have issues upgrading. You need to create overrides (which is super simple).
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    May 2012
    Posts
    10
    Vote Rating
    1
    ScottH is on a distinguished road

      0  

    Default


    The upgrade process is the reason I did this. The functionality (digging into the dom for the listitem location) for scrolling to a selected item was broken when the List was updated and improved.

    I well understand that anything I do in the framework is wiped every time we go through an framework update (I've gone through the process several times now), as it should be. The reason I posted this here is so that hopefully the functionality makes it into the next upgrade cycle so that I do not have to worry about managing overrides or digging into the dom.

    Look, I'm not complaining about the improvement, the performance improvements are very nice, but losing existing functionality is a real pain for the developers using your framework.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar