Skip to main content

template

specifies a template for DataView items

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

Example

var dataview = new dhx.DataView("dataview", {    itemsInRow: 4,     template: function(item) {        var 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. Render Template

The template function takes one parameter:

item(object) an object of a data item