Skip to main content

template

specifies a template for DataView items

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

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

The template function takes one parameter:

item(object) an object of a data item