lz.ReplicationManager
The controller for views replicated by data.

JavaScript: lz.ReplicationManager
extends <datapath> » <datapointer> » <node> » lz.Eventable »

When a view's datapath matches more than one data node, one instance of the view is created for each match. The replicated views are referred to as clones. When this happens, a replication manager (or a subclass of lz.ReplicationManager) is created to manage the clones. Replication managers are never directly instantiated — they are created when a datapath makes multiple matches.

If the replicated view was named, the clone manager takes over the named spot in the parent. The example below demonstrates this, and shows how to reference individual clones.

In the example that follows, a view, called replView is bound to a dataset somedata. For each matching node in the dataset, a new view is created. These views contain the text of the dataset. In other words, the single line

 <view name="replView" datapath="somedata:/*">
 
 

causes the creation of five views (because there were five elements in the dataset that matched the selection criteria). These "cloned" views are numbered successively, starting with zero. The highlighted section of the code below shows how to use the getCloneNumber method to access each replicated view.

<canvas height="140">
   <dataset name="somedata">
     <one/> <two/> <three/> <four/> <five/>
 
   </dataset>
   <simplelayout/>
   <button onclick="moveClone()">
     Move clone 
     <method name="moveClone">
       var nextClone = replView.getCloneNumber(this.cnum++);
       if (nextClone == null) {
         this.cnum = 0;
         var nextClone = replView.getCloneNumber(this.cnum++);
       }
       nextClone.setAttribute('x', nextClone.x + 10);
     </method>
     <attribute name="cnum" value="0"/>
 
   </button>
   <view name="replView" datapath="somedata:/*">
     <text datapath="name()"/>
   </view>
 </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
clones   [lz.node]   read/write
  The views which this LzReplicationManager has created.
nodes   [*]   read/write
  The data that this replication manager will map to views
visible boolean Boolean true initialize-only
  Globally controls the visibility of the clones this replication manager creates.

Attributes inherited from <datapath>

axis, pooling, replication, sortorder, sortpath, spacing

Attributes inherited from <datapointer>

context, p, rerunxpath, xpath

Methods

getCloneForNode()
lz.ReplicationManager.getCloneForNode(p : lz.DataElement, dontmake);
Returns a clone which is mapped to the given data node.
Parameter Name Type Description
p lz.DataElement The data node for which to return the clone.
dontmake    
Returns Type Description
  lz.view A clone mapped to the given data.

getCloneNumber()
lz.ReplicationManager.getCloneNumber(n : Number);
Retuns a pointer to the nth clone controlled by the replication manager
Parameter Name Type Description
n Number The zero-based offset of the clone to retrieve
Returns Type Description
  lz.view A pointer to the nth clone

Methods inherited from <datapath>

setNodes, setSelected, updateData

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onclones Sent when clones is changed
onnodes Sent when nodes is changed
onvisible Sent when visible is changed

Events inherited from <datapointer>

onerror, ontimeout

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy