1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    146
    Answers
    5
    Vote Rating
    4
    incutonez is on a distinguished road

      0  

    Default 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:

    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()
      });
    });
    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.

    If anyone has any insight, that'd be awesome! Thanks.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,872
    Answers
    652
    Vote Rating
    438
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Based on your model, the quickest would be to add Dan again if he belonged to both groups

    Code:
          {name: 'dan aykroyd', profession: 'ghostbuster'},
          {name: 'dan aykroyd', profession: 'musician'},
    You would have to make changes to your model if this was too clumsy.

    Scott.

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    146
    Answers
    5
    Vote Rating
    4
    incutonez is on a distinguished road

      0  

    Default


    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?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,872
    Answers
    652
    Vote Rating
    438
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Based on your current data, how do we know Dan was also a Blues Brother?

    {name: 'dan aykroyd', profession: 'ghostbuster'}
    Scott.

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Posts
    146
    Answers
    5
    Vote Rating
    4
    incutonez is on a distinguished road

      0  

    Default


    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.

Thread Participants: 1

Tags for this Thread