Skip to content

Commit 5d09a23

Browse files
committed
Update header dynamically
1 parent 6dcfb9c commit 5d09a23

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

paper-datatable-column.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
* @type String
4040
* @required
4141
*/
42-
header: String,
42+
header: {
43+
type: String,
44+
notify: true,
45+
observer: '_headerChanged'
46+
},
4347
/**
4448
* The property to be used from `data` for this column
4549
*
@@ -434,8 +438,10 @@
434438
}else if(type.toLowerCase() == 'number'){
435439
return 'number';
436440
}
437-
}
438-
441+
},
442+
_headerChanged: function(header) {
443+
this.fire('header-changed');
444+
},
439445

440446
});
441447
})();

paper-datatable.html

+8-2
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,15 @@
510510

511511
_queryAndSetColumns: function(){
512512
var columns = this.queryAllEffectiveChildren('paper-datatable-column');
513-
columns.forEach((column) => {
513+
columns.forEach((column, index) => {
514514
if(!column.beenAttached.state.ready){
515515
column.parentNodeRef = this;
516516
this.async(function(){
517517
column._registerEvilFunctions();
518518
column.beenAttached.ready();
519519
});
520+
column.index = index;
521+
this.listen(column, 'header-changed', '_updateHeaderColumn');
520522
}
521523
});
522524
this.set('_columns', columns.filter((column) => !column.inactive));
@@ -1098,7 +1100,11 @@
10981100

10991101
}
11001102
}
1101-
}
1103+
},
1104+
_updateHeaderColumn: function(event){
1105+
var column = Polymer.dom(event).localTarget;
1106+
this.notifyPath(`_columns.${column.index}.header`, this._columns[column.index].header);
1107+
},
11021108

11031109
});
11041110
})();

0 commit comments

Comments
 (0)