thinkmap.entitylist.EntityList

Jump To: Members Events

An EntityList represents a way building a list or tabular element representation of entities.

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.

Examples:

Make an entity list using a display as the source and uses the appropriate label for the given type. The parent element is the element with id 'nodeList' var display = new thinkmap.display.Display(); thinkmap.entitylist.list(document.getElementById('nodeList')) .observe(display) .label(function(entity) { 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; } });
Make an entity list that accepts only movies and creates tabular data, passing the dom element with id movieTable to the list 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(); });
Create an entity list that adds classes for mouse clicks, mouse overs, and mouse outs. 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'); });

Instance Methods

Events

fired when a row in the list is moused out. The parameter is the entity and the list element

mouseover : function ( thinkmap.graph.Entity , Element )

fired when a row in the list is moused over.The parameter is the entity and the list elementt

click : function ( thinkmap.graph.Entity , Element )

fired when a row in the list is clicked.The parameter is the entity and the list element

addentity : function ( thinkmap.graph.Entity , Element )

fired when an entity is added to this list. The parameter is the entity added and the element representing it

removeentity : function ( thinkmap.graph.Entity , Element )

fired when an entity is removed from this list. The paramter is the entity removed and the element representing it

refresh : function ( )

called when the entity list must rebuild itself. This typically only occurs if the structure of the list is changed at run time such as changing the condition or sorting function of a non-empty entity list