diff --git a/docs/timeline/index.html b/docs/timeline/index.html
index 0359e32c..a6665ec3 100644
--- a/docs/timeline/index.html
+++ b/docs/timeline/index.html
@@ -585,6 +585,13 @@ function (option, path) {
+
+ groupTemplate |
+ function |
+ none |
+ A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as argument, and must return HTML code as result. When the option groupTemplate is specified, the groups do not need to have a field content . See section Templates for a detailed explanation. |
+
+
height |
number or String |
@@ -1608,4 +1615,4 @@ var options = {
-
\ No newline at end of file
+
diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js
index e286ff9f..42ed8621 100644
--- a/lib/timeline/component/Group.js
+++ b/lib/timeline/component/Group.js
@@ -81,8 +81,16 @@ Group.prototype._create = function() {
*/
Group.prototype.setData = function(data) {
// update contents
- var content = data && data.content;
+ var content;
+ if (this.itemSet.options && this.itemSet.options.groupTemplate) {
+ content = this.itemSet.options.groupTemplate(data);
+ }
+ else {
+ content = data && data.content;
+ }
+
if (content instanceof Element) {
+ this.dom.inner.appendChild(content);
while (this.dom.inner.firstChild) {
this.dom.inner.removeChild(this.dom.inner.firstChild);
}
diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js
index cd763249..b6ac97ab 100644
--- a/lib/timeline/component/ItemSet.js
+++ b/lib/timeline/component/ItemSet.js
@@ -280,7 +280,7 @@ ItemSet.prototype._create = function(){
ItemSet.prototype.setOptions = function(options) {
if (options) {
// copy all options that we know
- var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'groupOrder', 'dataAttributes', 'template','hide', 'snap'];
+ var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'groupOrder', 'dataAttributes', 'template','groupTemplate','hide', 'snap'];
util.selectiveExtend(fields, this.options, options);
if ('orientation' in options) {
diff --git a/lib/timeline/optionsTimeline.js b/lib/timeline/optionsTimeline.js
index 5666e76b..81585612 100644
--- a/lib/timeline/optionsTimeline.js
+++ b/lib/timeline/optionsTimeline.js
@@ -104,6 +104,7 @@ let allOptions = {
snap: {'function': 'function', 'null': 'null'},
start: {date, number, string, moment},
template: {'function': 'function'},
+ groupTemplate: {'function': 'function'},
timeAxis: {
scale: {string,'undefined': 'undefined'},
step: {number,'undefined': 'undefined'},