Jump to content

GroupingFeature: Use a other column for Group Title in uniDBGrid


erich.wanker

Recommended Posts

Hi,

i use following code to display the total count of a Group in the Groupheade

function beforeInit(sender, config) 
{
    var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
        groupHeaderTpl: new Ext.XTemplate(
            '{columnName}: {name} ({[this.countTotal(values.rows)]})',
            '', {
                countTotal: function(records) {
                    var totalSum = 0;
                    totalSum = records.length;
                    return totalSum;
                }
            }
        ),
        hideGroupedHeader: true
    });
    config.features = [groupingFeature]
}

My basic Groupfield is GROUPNUMBER  (this is not changeable)

So the outpu of GroupHeader is: Groupnumber 12345 (999)  

Now i want to ADD the value of database-field "groupname" 

It should output a GroupHeader: Groupnumber 12345  - Groupname This is a Textttext stored in the field "groupname"   (999)  

 

i found this source from mhmda:

function beforeInit(sender, config)
{ 
 config.groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
   groupHeaderTpl:new Ext.XTemplate('{[this.getGroupTitle(values.rows[0])]}',
    {
      getGroupTitle: function(values) {
             if(values.data[1]=='') 
              return 'My custom title: '+values.data[8];/*<--[8]field index*/
             else 
              return 'Other title: '+values.data[2];/*<--[2]field index*/
        }
     })   
  });  
  config.features= [config.groupingFeature];
 }

how can i combinate this two things???

 

Link to comment
Share on other sites

TESTCASE 

 

Between Output of CountryGroup       and      TotalCount      i want the value of field "City" 

Description: My Datastructure is simmilar to the records of Group "British West Indies" - all "Citys" are the same .. which record of the group is used to get the "Grand Cayman"-Text doesnt matter 

uni2.jpeg.307519c7bebed0eea0f0036289527076.jpeg

testcase.zip

Link to comment
Share on other sites

20 hours ago, erich.wanker said:

TESTCASE 

 

Between Output of CountryGroup       and      TotalCount      i want the value of field "City" 

Description: My Datastructure is simmilar to the records of Group "British West Indies" - all "Citys" are the same .. which record of the group is used to get the "Grand Cayman"-Text doesnt matter 

uni2.jpeg.307519c7bebed0eea0f0036289527076.jpeg

testcase.zip 32.58 kB · 1 download

Hello

Please use below code. (Please use children instead of rows and rows is deprecated)

PRO TIP : add {[console.log(values)]} into groupHeaderTpl to see the values in the console.

function beforeInit(sender, config)
{
                      config.groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
                        groupHeaderTpl: new Ext.XTemplate('{[this.getGroupTitle(values.rows[0]]}', {
                            getGroupTitle: function (values) {
                                if (values.data[0] == '')
                                    return 'Alle 8D Änderungsreporte ohne Gruppenzuordnung';
                                else
                                    return 'Gruppenname: <b>' + (values.data[0]).replace(/[&\/\\#,+()$~%.":*?<>{}]/g, "");
                                '</b>';
                            }
                        })
                    });
                    config.features = [config.groupingFeature];
                    var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
                        groupHeaderTpl: new Ext.XTemplate('{columnName}: {name} - 1st CountryName: {[values.children.at(0).get(4)]}   -  TotalCount: ({[this.countTotal(values.children)]})', '', {
                            countTotal: function (records) {
                                var totalSum = 0;
                                totalSum = records.length;
                                return totalSum;
                            }
                        }),
                        hideGroupedHeader: true
                    });
                    config.features = [groupingFeature]
}

image.png.ffb1a37219a14f374dc756207e5d3cdc.png

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...