TreeGrid save state example

You can reload page. The tree state is saved.

Root node 1Additional info
Node 1-1Additional info
Node 1-2Additional info
Node 1-2-1Additional info
Root node 2Additional info
Node 2-1Additional info
Node 2-2Additional info
Node 2-2-1Additional info

Code


<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <title>Jquery-treegrid basic example</title>

    <link rel="stylesheet" href="../css/jquery.treegrid.css">

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="../js/jquery.treegrid.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
        $('.tree').treegrid({
          'initialState': 'collapsed',
          'saveState': true,
        });
      });
    </script>

  </head>
  <body>

      <table class="tree">
        <tr class="treegrid-1">
          <td>Root node 1</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-2 treegrid-parent-1">
          <td>Node 1-1</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-3 treegrid-parent-1">
          <td>Node 1-2</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-4 treegrid-parent-3">
          <td>Node 1-2-1</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-5">
          <td>Root node 2</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-6 treegrid-parent-5">
          <td>Node 2-1</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-7 treegrid-parent-5">
          <td>Node 2-2</td><td>Additional info</td>
        </tr>
        <tr class="treegrid-8 treegrid-parent-7">
          <td>Node 2-2-1</td><td>Additional info</td>
        </tr>        
      </table>		  

  </body>
</html>