diff --git a/docs/timeline/index.html b/docs/timeline/index.html
index eaa79b60..9961039e 100644
--- a/docs/timeline/index.html
+++ b/docs/timeline/index.html
@@ -580,6 +580,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 |
@@ -1591,4 +1598,4 @@ var options = {
-
\ No newline at end of file
+
diff --git a/lib/timeline/component/Group.js b/lib/timeline/component/Group.js
index 226ebab6..b125773a 100644
--- a/lib/timeline/component/Group.js
+++ b/lib/timeline/component/Group.js
@@ -81,9 +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);
+ this.dom.inner.appendChild(content);
}
else if (content !== undefined && content !== null) {
this.dom.inner.innerHTML = content;
diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js
index 43c27871..f6a498ea 100644
--- a/lib/timeline/component/ItemSet.js
+++ b/lib/timeline/component/ItemSet.js
@@ -279,7 +279,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 7082e8a5..d05bfc0c 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'},