1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    9
    Vote Rating
    0
    dmp1126@gmail.com is on a distinguished road

      0  

    Default Unanswered: store grouping not working

    Unanswered: store grouping not working


    as the title states i am have difficulty getting my store grouping to work.


    Store:
    Code:
    Ext.define('ems.common.client.store.UserApplicationAccessStore', {
        extend: 'Ext.data.Store',
        storeId: 'userApplicationAccessStore',
        requires: ['ems.common.client.model.UserApplicationAccess'],
        model: 'ems.common.client.model.UserApplicationAccess',
        groupField: 'installationProgram',
        
        userId: null,
        applicationId: null,
        userRole: null,
        
        setUserRole: function(userRole)
        {
            if (userRole != this.userRole) {
                this.userRole = userRole;
                //if(userRole == 'program_user')
                //{
                this.groupField='installationProgramId';
                //}
                //else
                //{
                //    this.clearGrouping();
                //}
            }
            console.log(this.getGroups());
        },
    Grid:
    Code:
    Ext.define('ems.common.client.view.user.UserApplicationAccessGrid' , {
        extend: 'Ext.grid.Panel',
        alias: 'widget.userapplicationaccessgrid',    
        title: 'User Permissions',    
        selType: 'rowmodel',
        plugins: [
            Ext.create('Ext.grid.plugin.RowEditing', {
                clicksToEdit: 1,
                clicksToMoveEditor: 2, 
                autoCancel: false,
                listeners:{
                    'edit': function(e, editor) {
                    },
                    'canceledit': function(e, editor){
                        e.record.reject();
                    }
                }
            }
        )],
        features: [{
            ftype: 'grouping',
            //groupHeaderTpl: '{name} ({rows.length})',
            startCollapsed: true
        }]
    i have tried using pretty much everything that i have found in the docs, but nothing seems to solve my issue. Ive tried to use this.group('installationProgramId') instead of setting the group field and it still does not work. The closest that i have been able to get is the entire store in one group and not split like it should be.

    anyone see something that im missing?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,884
    Answers
    653
    Vote Rating
    440
    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


    I can only assume that it is related to your data not structured as you expect.

    The following should display grouping:

    Code:
    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        groupField: 'name',
        fields:['name', 'email', 'change'],
        data:{'items':[
            { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "change":100  },
            { 'name': 'Bart', "email":"bart@simpsons.com", "change":20  },
            { 'name': 'Bart', "email":"bart@simpsons.com", "change":25  },
            { 'name': 'Homer', "email":"home@simpsons.com",  "change":23   },
            { 'name': 'Homer', "email":"home@simpsons.com",  "change":34   },
            { 'name': 'Marge', "email":"marge@simpsons.com", "change":11   }
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
            { header: 'Name',  dataIndex: 'name' },
            { header: 'Email', dataIndex: 'email', flex: 1 },
            { header: 'Change', dataIndex: 'change' }
        ],
        features: [{
            ftype: 'grouping'
        }],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });
    Scott.‚Äč

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    9
    Vote Rating
    0
    dmp1126@gmail.com is on a distinguished road

      0  

    Default


    i dont think that it is an issue of the data structure. I have tried to use a property that i know 100% is in there and it still does not group properly.

    i have updated my store, model, and grid to see what is causing it with no results.

    Store
    Code:
    Ext.define('ems.common.client.store.UserApplicationAccessStore', {
        extend: 'Ext.data.Store',
        storeId: 'userApplicationAccessStore',
        requires: ['ems.common.client.model.UserApplicationAccess'],
        model: 'ems.common.client.model.UserApplicationAccess',
        
        userId: null,
        applicationId: null,
        userRole: null,
        
        setUserRole: function(userRole)
        {
            if (userRole != this.userRole) {
                this.userRole = userRole;
                if(userRole == 'program_user')
                {
                    //grouper = new Ext.util.Grouper({direction: 'ASC', property:'installationName'});
                    //this.group(grouper);
                    this.group('installationName');
                }
                else
                {
                    this.clearGrouping();
                }
            }
        },

    Model:
    Code:
    Ext.define('ems.common.client.model.UserApplicationAccess', {
        extend: 'Ext.data.Model',    
    
        fields: [
            // These correlate with the properties within server/model/User.cfc
            {name: 'id', type: 'int'},
            {name: 'permission', type: 'string'},
            {name: 'installationProgram'},
            {name: 'installationProgramId', type: 'int'},
    
            {name: 'installationName', 
             convert: function(v, record)
             {
                 if(Ext.isDefined(record.installationProgram))
                 {
                     console.log(record.get('installationProgram').installation.name);
                     return record.get('installationProgram').installation.name;
                 }
             }}

    the console log comes back everytime with a name, so i really dont think that it is a data structure issue.

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    9
    Vote Rating
    0
    dmp1126@gmail.com is on a distinguished road

      0  

    Default


    issue has been resolved, thank you for the help.

Thread Participants: 1

Tags for this Thread