title: agGrid custom cell editor; returning object to Angular component
body: <p>I am attempting to write a custom cell editor for agGrid implemented in Angular.  In my grid I show the a user readable value of an object within my node, but the object has an <code>id</code> which is used throughout my Angular application.  I am trying create an editor in which the user can select basis the user readable value only, but where the editor returns both values so that my app component can use its <code>id</code>.</p>
  
  <p>For example, in my app component I have the following <code>columnDefs</code> and <code>rowData</code>:</p>
  
  <pre><code>columnDefs = [
        { headerName: 'City', field: 'city', editable: true, 
            cellEditor: 'cityEditor'},
    ];
  
  rowData = [
        { 'id': 1, 'city': 'Paris' },
        { 'id': 4, 'city': 'Amsterdam' },
    ]; 
  </code></pre>
  
  <p>In my external editor component I have a dataset to select from:</p>
  
  <pre><code>allCitiesRowData = [
          { 'id': 1, 'city': 'Paris', 'country': 'France' },
          { 'id': 2, 'city': 'London', 'country': 'United Kingdom' },
          { 'id': 3, 'city': 'Berlin', 'country': 'Germany' },
          { 'id': 4, 'city': 'Amsterdam', 'country': 'The Netherlands' },
      ];
  </code></pre>
  
  <p>When the user selects my editor component creates an object <code>selectedCity</code> with the <code>id</code> and <code>city</code>, for example <code>selectedCity = { 'id': 4, 'city': 'Amsterdam' }</code>.</p>
  
  <p>When the <code>stopEditing()</code> is called I can return only 1 value, so for example:</p>
  
  <pre><code>getValue(): any {
      return this.selectedCity.city;
  }
  </code></pre>
  
  <p>But in this case I have obviously not returned the <code>id</code> and my <code>rowData</code> nodes will not be correctly updated.  Had I returned <code>selectedCity.id</code> or <code>selectedCity</code> the edited cell would not show the user readable value of <code>selectedCity.city</code>.</p>
  
  <p>Some things I have considered:</p>
  
  <ul>
  <li><p>Redesign rowData so that the city is an object of both <code>id</code> and <code>city</code>, then I could return the <code>selectedCity</code> as a direct match.  However I don't think agGrid can hold an object in a cell and only show one of its properties. <strong>Edit</strong>. I realise that a custom cellRenderer could perhaps support this.</p></li>
  <li><p>Use <code>getCellEditorInstances(params)</code> in my app component to get the value of <code>selectedCity</code> however this seems hard as <code>selectedCity</code> is set at time of <code>stopEditing()</code> and also I would need to find the node that I was editing to set the value which doesn't sound to me like a robust solution.</p></li>
  </ul>
  
  <p>In a agGrid cell editor, can I return more than the value of the cell so that I can update the cell as well as a secondary value?</p>