title: ag-grid: hierarchical tree of referenced nodes: how to make the referenced attributes editable?
body: <p>I am testing the awesome <a href="https://ag-grid.com" rel="nofollow">ag-Grid</a> component (really cool!) for a new Angular2 project. It should be used to display a CAD model structure with a "structure" (aka "tree"), and each node being the attributes of a CAD model.</p>
  
  <p>Now, it is well possible to make a tree in ag-Grid. In its simpliest form, the <code>data</code> property holds the properties of the node (CAD model attributes). In this case, I can easily make the cells editable by assigning the property <code>editable: true</code> to the columnDefs.</p>
  
  <p>However, the problem is, that if a CAD model is used in many places of the structure (tree), and one is edited, all others do not change.</p>
  
  <p>Instead, the CAD models (the nodes) should in fact be <strong>references</strong> to the data, not the data itself. Ok, no problem with ag-Grid. Here you can see the comparison between a tree with <strong>copied</strong> nodes and a tree with <strong>referenced</strong> nodes:</p>
  
  <h3>Nodes are copied in the tree</h3>
  
  <p>ag-Grid's rowData:</p>
  
  <pre><code>rowData = [
    {
      data: { modelName: 'partA', weight: 12.5 }
      children: [ ... ]
    }
  ];
  </code></pre>
  
  <p>The ag-Grid's column definition would be:</p>
  
  <pre><code>{
    headerName: 'weight',
    field: 'weight',
    editable: true
  }
  </code></pre>
  
  <h3>Nodes are referenced in the treee</h3>
  
  <p>ag-Grid's rowData:</p>
  
  <pre><code>rowData = [
    {
      data: { model: MODEL_OBJECT }
      children: [ ... ]
    }
  ];
  </code></pre>
  
  <p>where MODEL_OBJECT is a javascript reference to the model object, which would be e.g.:</p>
  
  <pre><code>var modelA = { modelName: 'partA', weight: 12.5 }
  </code></pre>
  
  <p>And change the column definitions to:</p>
  
  <pre><code>{
    headerName: 'weight',
    valueGetter: 'data.weight',
    editable: true
  }
  </code></pre>
  
  <p>See? The same properties are shown in the tree, but in fact they are fetched from the referenced POJS object. Thus, the models will be <strong>shared</strong> among their usages in the tree.</p>
  
  <p>All well so far. But now - since there is a <code>valueGetter</code> for the column, the column <code>weight</code> is not directly editable. To be more precise, the ag-Grid allows to edit it, but it does not modify the value. Well, this is understandable since the valueGetter is acting as a mapping function which may not be "reversible" in the other direction. Consider something like 'data.firstName + data.lastName': how in the world should ag-grid know how to update <code>data.firstname</code> or <code>data.lastName</code> if the user enters another value for the column.</p>
  
  <p>My question: how can I achieve the goal of having editable cells of <strong>referenced</strong> tree nodes? The intended effect is that if I edit the properties of a CAD model in one place of the tree, then the grid updates all other occurrences automatically, through the references.</p>