1. #1
    Sencha User
    Join Date
    Nov 2011
    Location
    Renfrew
    Posts
    74
    Vote Rating
    2
    Answers
    1
    tmcdonald is on a distinguished road

      0  

    Default Unanswered: Deselecting list items to remove highlighted selection

    Unanswered: Deselecting list items to remove highlighted selection


    I have a list that when the onTap event fires, I want to deselect the item. If I use this, it works, however, there are errors in the console: Uncaught TypeError: Object [object Object] has no method 'getSelectedRecords'

    Code:
    onProfileTap: function(dataview, index, target, record, e, options) {
         // process record
    
        // Deselect the item
        dataview.deselect(dataview.getSelectedRecords());   
    }

    It appears that getSelectedRecords() is removed in 2.0.0.

    I tried using getSelection() and passing the index to dataview.deselect, but neither removes the highlighted selection.
    I also tried adding allowDeselect: true, and allowDepress: true in the list on the view, as suggested in an earlier forum topic.

    I'd like to know how I can get the highlight to remove with a valid call. I'm also curious to understand why the getSelectedRecords returns an error - but still removes the highlight.

    Thanks for any help.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    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

      1  

    Default


    Here is a test case:

    Code:
    new Ext.dataview.List({
        fullscreen : true,
        mode       : 'SIMPLE',
        itemTpl    : '{text}',
        store      : {
            fields  : ['text'],
            data    : [
                { text : 'One'   },
                { text : 'Two'   },
                { text : 'Three' },
                { text : 'Four'  },
                { text : 'Five'  }
            ]
        },
        items      : [
            {
                xtype  : 'toolbar',
                docked : 'top',
                items  : [
                    {
                        xtype   : 'button',
                        text    : 'Deselect *',
                        ui      : 'confirm',
                        handler : function(button) {
                            var list       = button.up('list'),
                                selections = list.getSelection();
    
                            list.deselect(selections);
                        }
                    }
                ]
            }
        ]
    });
    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
    Nov 2011
    Location
    Renfrew
    Posts
    74
    Vote Rating
    2
    Answers
    1
    tmcdonald is on a distinguished road

      0  

    Default


    I think I missed some detail on this. I'm trying to automatically deselect the selected item after I've clicked on a list item.

    This way after the selected item is used to build the a view and pushed, if I user clicks "back", the list items are all unselected.

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Location
    Renfrew
    Posts
    74
    Vote Rating
    2
    Answers
    1
    tmcdonald is on a distinguished road

      1  

    Default


    I found out how to accomplish this:

    Code:
            // Deselect the list item
            setTimeout(function(){dataview.deselect(index);}, 500);

Thread Participants: 1