Skip to content

Commit e444ca5

Browse files
authored
Merge pull request #29 from RallyTechServices/summaryRow
summary row columns for PlanEstimate, TaskRemainingTotal, ToDo and Ta…
2 parents f263b23 + 4bc5071 commit e444ca5

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed

src/javascript/app.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Ext.define("custom-grid-with-deep-export", {
8686
if (this.searchAllProjects()) {
8787
dataContext.project = null;
8888
}
89+
var summaryRowFeature = Ext.create('Rally.ui.grid.feature.SummaryRow');
8990
this.gridboard = this.down('#display_box').add({
9091
xtype: 'rallygridboard',
9192
context: context,
@@ -118,9 +119,9 @@ Ext.define("custom-grid-with-deep-export", {
118119
{
119120
ptype: 'rallygridboardfieldpicker',
120121
headerPosition: 'left',
121-
modelNames: this.modelNames
122-
//stateful: true,
123-
//stateId: this.getContext().getScopedStateId('columns-example')
122+
modelNames: this.modelNames,
123+
stateful: true,
124+
stateId: this.getContext().getScopedStateId('field-picker')
124125
},
125126
{
126127
ptype: 'rallygridboardactionsmenu',
@@ -145,8 +146,25 @@ Ext.define("custom-grid-with-deep-export", {
145146
context: dataContext
146147
},
147148
columnCfgs: [
148-
'Name'
149-
]
149+
'Name',
150+
{
151+
dataIndex: 'PlanEstimate',
152+
summaryType: 'sum'
153+
},
154+
{
155+
dataIndex: 'TaskRemainingTotal',
156+
summaryType: 'sum'
157+
},
158+
{
159+
dataIndex: 'ToDo',
160+
summaryType: 'sum'
161+
},
162+
{
163+
dataIndex: 'TaskEstimateTotal',
164+
summaryType: 'sum'
165+
}
166+
],
167+
features: [summaryRowFeature]
150168
},
151169
height: this.getHeight()
152170
});

src/javascript/utils/overrides.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,61 @@ Ext.override(Rally.ui.inlinefilter.PropertyFieldComboBox, {
2323
*/
2424
defaultWhiteListFields: ['Milestones','Tags']
2525
});
26+
27+
Ext.override(Rally.ui.grid.TreeGrid, {
28+
// Override needed to allow summaryType to be restored when a column with
29+
// summaryType config is added by the field picker
30+
_mergeColumnConfigs: function(newColumns, oldColumns) {
31+
return _.map(newColumns, function(newColumn) {
32+
// If the newly selected column is currently in oldColumns (this.columns), then
33+
// use the in-use column config to preserve its current settings
34+
var result = newColumn;
35+
var newColumnName = this._getColumnName(newColumn);
36+
var oldColumn = _.find(oldColumns, {dataIndex: newColumnName});
37+
if (oldColumn) {
38+
result = this._getColumnConfigFromColumn(oldColumn);
39+
} else if ( this.config && this.config.columnCfgs ) {
40+
// Otherwise, if the newly selected column appears in the original columnCfgs
41+
// use that config. (This allows the column picker to get any renderers or summary
42+
// config from the column config)
43+
var columnCfg = _.find(this.config.columnCfgs, {dataIndex: newColumnName});
44+
if ( columnCfg ) {
45+
result = columnCfg;
46+
}
47+
}
48+
49+
return result;
50+
}, this);
51+
},
52+
53+
// Override needed to allow summaryType to be included when a column is restored
54+
// from state.
55+
_applyStatefulColumns: function(columns) {
56+
// TODO (tj) test default columns
57+
if (this.alwaysShowDefaultColumns) {
58+
_.each(this.columnCfgs, function(columnCfg) {
59+
if (!_.any(columns, { dataIndex: this._getColumnName(columnCfg) })) {
60+
columns.push(columnCfg);
61+
}
62+
}, this);
63+
}
64+
65+
if (this.config && this.config.columnCfgs) {
66+
// Merge the column config with the stateful column if the dataIndex is the same.
67+
// This allows use to pick up summaryType and custom renderers
68+
_.each(this.config.columnCfgs, function(columnCfg) {
69+
// Search by dataIndex or text
70+
var columnName = this._getColumnName(columnCfg);
71+
var columnState = _.find(columns, function(value) {
72+
return (value.dataIndex === columnName || value.text === columnName);
73+
});
74+
if (columnState) {
75+
// merge them (add renderer)
76+
_.merge(columnState, columnCfg);
77+
}
78+
}, this);
79+
}
80+
81+
this.columnCfgs = columns;
82+
}
83+
});

0 commit comments

Comments
 (0)