Skip to main content

template

Optional. Specifies a template for DataView items

template?: (item: object) => string;

Parameters:

The template function takes one parameter:

  • item: object - an object of a data item

Example

const dataview = new dhx.DataView("dataview_container", {
itemsInRow: 4,
template: function(item) {
let template = "<div className='item_wrap'>";
template += "<img className='image' src=" + "..images/" + item.thumbnailName + " />";
template += "<h2 className='title'>" + item.value + "</h2>";
template += "<p className='description'>" + item.shortDescription + "</p>";
template += "</div>";
return template;
}
});

Related sample: Dataview. With template