title: customizing ag-grid to set a max number of selectable rows
body: <p>I am trying to customize a data table using <code>ag-grid</code> in my Angular 1.5 based project. The customization is that the user is allowed to select a maximum number of rows in the table, for example, the maximum is 2. </p>
  
  <p>I have the following code by using <code>node.setSelected(false)</code> that I found in the documentation page <a href="https://www.ag-grid.com/angular-grid-selection/index.php" rel="nofollow">here</a>, but I got the error: <code>node.setSelected is not a function</code> when the selection exceeds the maximum of 2.</p>
  
  <pre><code>var gridOptions = {
      columnDefs: columnDefs,
      rowSelection: 'multiple',
      onRowSelected: onRowSelected
  };
  
  
  function onRowSelected(event) {
                  var curSelectedNode = event.node;
                  var selectionCounts = vm.gridOptions.api.getSelectedNodes().length;
                  if (selectionCounts &gt; 2) {
                      var oldestNode = vm.gridOptions.api.getSelectedNodes()[0]; // get the first node, to be popped out
                      oldestNode.setSelected(false); // causes the above 'not a function' error
                   }       
              }
  </code></pre>
  
  <p>Does anyone know what might be wrong with ag-grid for its <code>setSelected()</code> API? or any better way to do this customization?</p>