lontivero
lontivero

Reputation: 5275

How to get access to grouped records from groupHeaderTpl in grouped grid?

I´m working on an auditing results view. The view consists basically on a grid where user can see who changed which values, when he/she did it, from what ip address, etc.

enter image description here

The point is that I want to group records by 'changeset' field (a GUID field existing in the model which is useful to know that a set of changes were performed as part of one bigger operation) and display in the group header a little summary about the changeset.

For example, I would like to show: "Date: 12/12/2012 15:04:32 - User: ontivero - Updated subscription details".

The first problem that I have is 'User' (or 'Changed By') is not available for the groupHeaderTpl template and the second problem is the grouped rows or records are not available neither. I need the rows because I have to analyse them in order to be able to display a more useful information.

Summarizing, the question should be: how can i have access to the grouped rows to use them in the groupHeaderTpl template?

I have read the documentation (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.feature.Grouping) but the 'children' property doesn´t work.

Upvotes: 3

Views: 8457

Answers (1)

lontivero
lontivero

Reputation: 5275

I found the answer digging deeper in the documentation (see the comments there): http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.feature.Grouping-cfg-groupHeaderTpl

The key is to specify IDs for the columns asn that´s all.

var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
        groupHeaderTpl: '{[values.rows[0].columnId]}'
});


Ext.create('Ext.grid.Panel', {
    columns: [{
        id:'columnId',
        dataIndex: 'testData'
    }],
    features: [groupingFeature]
    ...
}); 

Upvotes: 3

Related Questions