title: Select All rows in Jquery Datatables
body: <p>I have a datatables in which I can select multiple row onclick but how can I select all the row on a click of button and at the same time all rows are highlighted with selection (Can you please give example of selection for current page and all the pages). I have written a code to get multiple selected value.</p>
  
  <p>Checkbox will also do but then how to get selected value.</p>
  
  <p><strong>Below is code for single and multiple selection.</strong></p>
  
  <pre><code> var oTable = $("#example").dataTable();
  
      $('#example tbody').on('click', 'tr', function() {
                          $(this).toggleClass('selected');
  
      });
  </code></pre>
  
  <p><strong>Code to get selected value on button submit.</strong></p>
  
  <pre><code>var row = oTable.rows('.selected').data();
  
  var jsonArr = "[";
  
          if(row != null &amp;&amp; row.length){
  
              for (var i = 0; i &lt; row.length; i++) {
                  var row1 = row[i]; // this will give me one row details
                          // row1[0] will give me column details
                          jsonArr = jsonArr + "{\"ID\":" + row1[0] + "},";
  
                  }   
               jsonArr = jsonArr + "]";
  </code></pre>