@@ -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