We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10378
    • 375 Posts
    Hi,

    I have a MODx.grid with a configured grouping view. The problem is: grouping only works as expected, if I manually sort the grid by the grouping field (clicking the column header). Otherwise the grouping doesn't fully work as some groups are listed twice.

    Please have a look at the attached screenshot! (by the way: spoiler alert for the upcoming GoodNews add-on!)

    I had a deep look at the MODx system settings grid and the corresponding processor to see how they did it and can't find any difference so far.

    Is there anything specific to pay attention for the processor?

    Hope somebody can help!
    Thanks Martin


    Here is the part of the ExtJS code with the grid configuration:

    GoodNews.grid.Categories = function(config) {
        config = config || {};
        
        Ext.applyIf(config,{
            id: 'goodnews-grid-categories'
            ,url: GoodNews.config.connectorUrl
            ,baseParams: { action: 'mgr/category/getList' }
            ,fields: [
                'id'
                ,'name'
                ,'description'
                ,'goodnewsgroup_name'
                ,'membercount'
                ,'public'
                ,'menu'
            ]
            ,grouping: true
            ,groupBy: 'goodnewsgroup_name'
            ,singleText: _('goodnews.category')
            ,pluralText: _('goodnews.categories')
            ,primaryKey: 'name'
            ,sortBy: 'name'
            ,sortDir: 'ASC'
            ,paging: true
            ,remoteSort: true
            ,emptyText: _('goodnews.categories_none')
            ,save_action: 'mgr/category/updateFromGrid'
            ,autosave: true
            ,autoExpandColumn: 'description'
            ,collapseFirst: false
            ,columns: [{
                header: _('goodnews.category_name')
                ,dataIndex: 'name'
                ,sortable: true
                ,width: 150
                ,editable: true
                ,editor: { xtype: 'textfield' }
            },{
                header: _('goodnews.category_description')
                ,dataIndex: 'description'
                ,sortable: false
                ,width: 250
                ,editable: true
                ,editor: { xtype: 'textfield' }
            },{
                header: _('goodnews.category_usergroup')
                ,dataIndex: 'goodnewsgroup_name'
                ,sortable: true
                // this is temporary set to visible for testing!
                //,hidden: true
                ,width: 100
                ,editable: false
            },{
                header: _('goodnews.category_public')
                ,dataIndex: 'public'
                ,align: 'center'
                ,sortable: false
                ,width: 80
                ,editable: true
                ,editor: { 
                    xtype: 'combo-boolean'
                    ,renderer: 'boolean'
                }
            },{
                header: _('goodnews.category_membercount')
                ,dataIndex: 'membercount'
                ,align: 'center'
                ,sortable: false
                ,width: 100
                ,editable: false
            }]
            ... // code goes on here
    
    

    This question has been answered by markh. See the first response.

      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
    • discuss.answer
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Been a while that I used grouping, but I'm pretty sure your processor will need to make sure it's always sorted on what you're grouping if you want it to work properly. Luckily you can just call xPDOQuery->sortby multiple times so if you add the sort on the groups in prepareQueryBeforeCount, it should work fine.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 10378
        • 375 Posts
        Quote from: markh at May 02, 2013, 11:24 AM
        Been a while that I used grouping, but I'm pretty sure your processor will need to make sure it's always sorted on what you're grouping if you want it to work properly. Luckily you can just call xPDOQuery->sortby multiple times so if you add the sort on the groups in prepareQueryBeforeCount, it should work fine.

        That's it Mark!
        As always fast and profound answer! Thanks a lot!

        I don't understand why such simple informations aren't included in MODx documentation?

        Greetings,
        Martin
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/