title: How can I programmatically select multiple rows in ag-Grid?
body: <p>I have an array of row ids, stored in <code>tempSelected</code>, and I would like to programmatically set each row in the list to selected. This is what I'm trying:</p>
  
  <pre><code>let len = tempSelected.length;
  this.gridApi.forEachNode(function (node) {
    for(let i=0; i&lt;len; i++){
      if(node.id === tempSelected[i]){
        node.setSelected(true);
      }
    }
  });
  </code></pre>
  
  <p>At the end of this loop, I want every row in <code>tempSelected</code> to be selected, but right now, only the last id in the <code>tempSelected</code> array gets selected, and the others are not.</p>
  
  <p>I have set <code>rowSelection = 'multiple'</code>, so it shouldn't be limited to 1 selection. I have also tried changing <code>node.setSelected(true);</code> to <code>node.setSelected(true, false);</code> based on what I read <a href="https://www.ag-grid.com/javascript-grid-selection/" rel="nofollow noreferrer">here on ag-grid's website</a>, but that didn't change the result.</p>
  
  <p>How can I select multiple nodes at once?</p>