Demo - Tree Grids

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<div class="container">

  <h1>
    Tree Grids</h1>
  <p>
    If your data items contain collections of child items,
    you may use the FlexGrid's <b>childItemsPath</b> to
    show the data as a tree.</p>

  <p>
    For example, consider a list of 'person' objects
    which have a 'children' property. The 'children' 
    property contains an array of more person objects.
    This is sometimes called a <i>homogeneous</i> 
    hierarchy.</p>
  <p>
    The grid below was built by binding the grid to
    the top-level persons list and setting the 
    <b>childItemsPath</b> property to 'children':</p>
    
  <label for="asTree">Show as Tree: </label>
  <input id="asTree" type="checkbox" checked="checked">
  
  <div id="familyGrid"></div>
  
  <p>
    There are also 'heterogeneous' hierarchies, where
    items at different levels have different types and
    different child item properties.</p>
  <p>
    For example, the grid below is bound to a collection
    of 'worker' objects which receive 'checks' which list
    'earnings':</p>
  <div id="workersGrid"></div>
  
</div>

CSS

.wj-flexgrid {
  max-height: 220px; 
  margin: 10px;
}
.wj-cell.wj-group {
  border: none;
}
.wj-cell.wj-group:not(.wj-state-selected):not(.wj-state-multi-selected) {
  background-color: white;
}
body {
   margin-bottom: 24px;
}

JavaScript

onload = function() {

	// family tree data (homogeneous collection)
	var family = [
  	{ name: 'Albert', children: [
    	{ name: 'Anton' },
    	{ name: 'Annette' },
    ]},
  	{ name: 'Benjamin', children: [
    	{ name: 'Bridget', children: [
	    	{ name: 'Billy' },
  	  	{ name: 'Bernard' },
      ] },
    	{ name: 'Bella' },
    	{ name: 'Bob' },
    ]},
  	{ name: 'Charlie', children: [
    	{ name: 'Chris' },
    	{ name: 'Connie' },
    	{ name: 'Carrie' },
    ]},
  	{ name: 'Douglas', children: [
    	{ name: 'Dinah' },
    	{ name: 'Donald' }
    ]},
  ];
  
  // family tree
  var familyGrid = new wijmo.grid.FlexGrid('#familyGrid', {
  	headersVisibility: 'None',
    childItemsPath: 'children',
  	itemsSource: family
  });
  familyGrid.columns[0].width = '*';
  
  // toggle family tree
  document.getElementById('asTree').addEventListener('click', function(e) {
  	familyGrid.childItemsPath = e.target.checked ? 'children'	: '';
  })

	// workers tree data (heterogeneous collection)
  var workers = [{
    name: 'Jack Smith',
    checks: [{
      name: 'check1',
      earnings: [
      	{ name: 'hourly', hours: 30.0, rate: 15.0 },
        { name: 'overtime', hours: 10.0, rate: 20.0 },
        { name: 'bonus', hours: 5.0, rate: 30.0}
      ]
    }, {
      name: 'check2',
      earnings: [
      	{ name: 'hourly', hours: 20.0, rate: 18.0 },
        { name: 'overtime', hours: 20.0, rate: 24.0 }
      ]
    }]
  }, {
    name: 'Jack Smith',
    checks: [{
      name: 'check1',
      earnings: [
        { name: 'hourly', hours: 30.0, rate: 15.0 },
        { name: 'overtime', hours: 10.0, rate: 20.0 }, 
        { name: 'bonus', hours: 5.0, rate: 30.0 }
      ]
    }, {
      name: 'check2',
      earnings: [
        { name: 'hourly', hours: 20.0, rate: 18.0 },
        { name: 'overtime', hours: 20.0, rate: 24.0 }
      ]
    }]
  }, {
    name: 'Jane Smith',
    checks: [{
      name: 'check1',
      earnings: [
        { name: 'hourly', hours: 30.0, rate:...