Constructs an EntityList using the given DOM Element as the parent container for the list.
The rows of the list are created depending on what type the parent element is. If the parent element is an orderered or unordered list (ol or ul) then the EntityList will create list elements (li) for each element. If the the parent is a table, then the EntityList will create a single table row with a single column (tr > td). For all other cases, the list will generate a div for each entity in the list.
There is also the option to create your own elements for each row for handling more sophisticated lists such as tables with multiple rows, etc.
var display = new thinkmap.display.Display();
thinkmap.entitylist.list(document.getElementById('nodeList'))
.observe(display)
.label(function(e) {
var data = entity.data;
if (entity.isType('movie')) {
return data.title;
} else if (entity.isType('person')) {
return data.lastname + ', ' + data.firstname;
} else {
return data.genrename;
}
});
thinkmap.entitylist.list(document.getElementById('movieTable'))
.observe(graph)
.condition(function(entity) {
return entity.isType('movie');
})
.createListElement(function(entity) {
var listElement = thinkmap.selection.select(document.createElement('tr'));
var data = entity.data;
listElement.append('td').text(data.title);
listElement.append('td').text(data.year);
listElement.append('td').text(data.rating);
listElement.append('td').text(data.stars);
return listElement.node();
});
thinkmap.entitylist.list(document.getElementById('listDiv'))
.observe(graph)
.condition(function(entity) {
return entity.isType('movie');
})
.label(function(entity) {
return entity.data.title;
})
.on('mouseout', function(entity, rowElement) {
thinkmap.select(rowElement).removeClass('mouseover');
})
.on('mouseover', function(entity, rowElement) {
thinkmap.select(rowElement).addClass('mouseover');
})
.on('click', function(entity, rowElement) {
thinkmap.select(rowElement).toggleClass('selected');
});