Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User DrunkenBeard's Avatar
    Join Date
    May 2011
    Posts
    55
    Vote Rating
    -2
    DrunkenBeard has a little shameless behaviour in the past

      0  

    Default Multiple redundant headers in Grouped List

    Multiple redundant headers in Grouped List


    Hi there,

    First, here's the code I'm using to populate my grouped list :

    Model :
    Code:
    Ext.define('App.model.User', {
        extend: 'Ext.data.Model',
        fields: ['id', 'name'],
     
        proxy: {
            type: 'ajax',
            url: 'app/remote/GetData.php',
            reader: {
                type: 'json',
                root: 'users'
            }
        }
    });
    Store :
    Code:
    Ext.define('App.store.Users', {
        extend: 'Ext.data.Store',
        requires: 'App.model.User',
        model: 'App.model.User',
    
    
        sorters: 'name',
        getGroupString : function(record) {
            return record.get('name')[0]
        }
    });
    List :
    Code:
    Ext.define('App.view.users.List', {
        extend: 'Ext.List',
        xtype: 'userslist',
    
    
        config: {
            flex: 1,
            store: 'Users',
    
    
            itemTpl: '{name}',
            grouped: true,
            indexBar: true
        }
    });
    List controller where the loading gets done :
    Code:
    Ext.define('App.controller.Users', {
        extend: 'Ext.app.Controller',
    
    
        stores: ['Users'],
    
    
        init: function() {
            this.control({
                '#reload': {
                    tap: this.loadUsersStore
                }
            });
        },
    
    
        loadUsersStore: function() {
            var usersStore = this.getUsersStore();
    
    
            usersStore.load();
        }
    });

    If you read the controller code you'll notice that I'm listening to the 'tap' event on a button and then loading the store. When I click on that '#reload' button it does the job indeed, but when I click on it again it creates double headers for my groups, then triple if I click again, and so on ... Here's a picture :




    I investigated the problem and it seems this is the faulty part of the framework :

    Code:
    findGroupHeaderIndices: function() {
        // Some stuff
    
        // Add header to an item if needed        
        for (; i < groupLn; i++) {
                firstGroupedRecord = groups[i].children[0];
                index = store.indexOf(firstGroupedRecord);
    
                // This is always true. For some reason even if firstGroupedRecord does belong to previousHeadersIndices the 'indexOf' method returns -1
                if (previousHeaderIndices.indexOf(firstGroupedRecord) == -1) {
                    me.doAddHeader(items[index], store.getGroupString(firstGroupedRecord));
                }
                newHeaderIndices.push(firstGroupedRecord);
        }
    }
    Hope it helps

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

Thread Participants: 1