1. #1
    Touch Premium Member
    Join Date
    Jan 2012
    Location
    Los Angeles, CA
    Posts
    32
    Answers
    1
    Vote Rating
    1
    melevine is on a distinguished road

      0  

    Default Answered: List: How to change selection after the store is updated

    Answered: List: How to change selection after the store is updated


    I have a field in my model that I'm using to determine if the list item should be selected or not. So when the store changes I want to update the selection in the view to reflect the new model data.

    I have a field on my model 'current', that when set to true means the corresponding list view item should be selected.
    Code:
    var isSelected = record.get('current');
    Code:
       constructor: function(config) {
            this.callParent(arguments);
            var store = this.getStore();
            store.addListener('datachanged', this.onStoreDataChanged, this);
            store.load();
       },
       ...
       onStoreDataChanged : function(store) {        index = store.find('current', true);
            if (index >= 0) {
                this.select(index);
            }
        }
    Seems simple enough, but I get an error:

    Uncaught TypeError: Cannot call method 'removeCls' of null Ext.define.doItemSelect
    ...

    I assume this is a timing issue, I'm probably trying to select the ui element before its been created. Whats the right way to do this? Is this 'datachanged' the wrong event to watch or is there a better way of doing this?

  2. Use the load event.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,672
    Answers
    3354
    Vote Rating
    748
    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


    Use the load event.
    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.

  4. #3
    Touch Premium Member
    Join Date
    Jan 2012
    Location
    Los Angeles, CA
    Posts
    32
    Answers
    1
    Vote Rating
    1
    melevine is on a distinguished road

      0  

    Default


    I think this exposed a bug in selection handling. No matter what I try I cannot clear the selection in my 'load' listener.

    Code:
    Ext.define('app.view.MyList', {
         extend : 'Ext.dataview.List',
    
         constructor : function(config) {
            this.callParent(arguments);
            var store = this.getStore();
            store.addListener('load', this.onStoreLoad, this);
            store.load();
        },
    
    
        config: {
            disclosure : true,
            itemTpl : '<strong>{foo}</strong><br><small>{bar}</small>',
        },
    
    
        onStoreLoad : function(store, records, successful) {
            index = store.find('current', true);
            this.deselect(this.getSelected().items);
       }
    });
    Here's how I reproduce it, load some initial data into the store, select something, update the data in the store, and nothing gets deselected. The weird thing is before updating the store, view.getSelected().items has my selection, after updating the store its empty, but the view still shows a selection on the page.

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