-
17 Aug 2012 9:09 AM #1
Unanswered: Putting a record into multiple groups.
Unanswered: Putting a record into multiple groups.
Is it possible to group a single record into multiple groups? Let's say I have the following code:
Don't read too much into the professions because this is a toy example, but let's say I want to group Dan Aykroyd into two groups... "ghostbuster" and "musician." However, I don't see any examples of this online, so I'm wondering if it can be done. It seems like it can be done because I'm under the assumption that a filter is applied to the store, so it should be possible, but I have been known to be wrong.Code:Ext.onReady(function() { var store = Ext.create('Ext.data.Store', { fields: ['name', 'profession'], groupField: 'profession', data: [ {name: 'jack johnson', profession: 'surfer'}, {name: 'dan aykroyd', profession: 'ghostbuster'}, {name: 'dwayne johnson', profession: 'actor'}, {name: 'chino moreno', profession: 'musician'} ] }); var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [{ text: 'Name', dataIndex: 'name', flex: 1 }, { text: 'Profession', dataIndex: 'profession', flex: 2 }], features: [{ftype: 'grouping'}], height: 400, width: 400, renderTo: Ext.getBody() }); });
If anyone has any insight, that'd be awesome! Thanks.
-
17 Aug 2012 9:52 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,183
- Vote Rating
- 194
- Answers
- 433
Based on your model, the quickest would be to add Dan again if he belonged to both groups
You would have to make changes to your model if this was too clumsy.Code:{name: 'dan aykroyd', profession: 'ghostbuster'}, {name: 'dan aykroyd', profession: 'musician'},
Scott.
-
17 Aug 2012 12:18 PM #3
Hmm, don't like that approach. What if I had 1,000 records and each one had 2 groups they belonged to? I'd have to copy/double my data... there's got to be a cleaner way.
Would it be possible to make profession an array and then group on the array of professions for that record?
-
17 Aug 2012 12:37 PM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,183
- Vote Rating
- 194
- Answers
- 433
Based on your current data, how do we know Dan was also a Blues Brother?
Scott.{name: 'dan aykroyd', profession: 'ghostbuster'}
-
17 Aug 2012 5:20 PM #5
Who said anything about him being a Blues Brother? Haha
But if one were to prove it, one would simply put on Soul Man.
But seriously, I don't have a way of showing he's an actor and a musician... I'm wondering if you can filter on an array though. May toy around with that idea.


Reply With Quote