-
16 Oct 2011 2:22 AM #1
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 :
Store :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' } } });
List :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 controller where the loading gets done :Code:Ext.define('App.view.users.List', { extend: 'Ext.List', xtype: 'userslist', config: { flex: 1, store: 'Users', itemTpl: '{name}', grouped: true, indexBar: true } });
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 :
Hope it helpsCode: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); } }
-
17 Oct 2011 7:08 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 434
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote