title: How to re-initialize DataTable in Jquery
body: <p>I have a requirement in which I have to store the state of the <strong>DataTable</strong> like <em>'pagination', 'sorting', 'search'</em> etc. For this I have set the '<strong>bStateSave</strong>' property to '<strong>True</strong>' and this is working pretty well. I know that 'bStateSave' save the state in the form of <strong>Cookie</strong>. Now I have another requirement in which I have to reset the <strong>DataTable</strong> and reinitialize it in case of User Login. </p>
  
  <p><strong>ForEx:</strong></p>
  
  <pre><code>if (sessionUserLogin == 'True') {
         $('#myTableId').dataTable({ "bStateSave": false, "bDestroy": true});            
         $('#myTableId').dataTable({ "bStateSave": true });
    }
     else {
           $("#myTableId").dataTable({ "bStateSave": true });
    }
  </code></pre>
  
  <p>As per above example the "<strong>sessionUserLogin</strong>" tells if the user login into the system, if this flag(<strong>sessionUserLogin</strong>) sets to True, I want to <strong>Destroy</strong> the previous state and <strong>initialize</strong> the table again so that it can continue saving the state. Else condition is used to handle the other postbacks in the system as after login of the user I want to maintain the state of the table even after the <strong>postbacks</strong> like any <strong>DropDown</strong> change or <strong>Saving</strong> the records.</p>
  
  <p>My above code works fine when the user login, I am able to clear the state of the table, but I am not able to initialize the table state again.</p>
  
  <p>I have gone through this <a href="http://datatables.net/docs/DataTables/1.9.4/DataTable.defaults.html#fnStateSave" rel="nofollow">URL</a>. But still not able to find the solution.</p>
  
  <p>Please help. Thanks in advance.  </p>