Wijmo 5 - ChildItemsPath Array

ChildItemsPath Array

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://cdn.wijmo.com/5.20153.109/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20153.109/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.20153.109/interop/angular/wijmo.angular.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20153.109/styles/wijmo.min.css">
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">

  <h2>
    Raw data.</h2>
  <p>
    In this case, do not set the <b>childItemsPath</b> property so
    the data is shown as a flat table.</p>
  <wj-flex-grid items-source="workers">
    <wj-flex-grid-column binding="name"></wj-flex-grid-column>
    <wj-flex-grid-column binding="hours"></wj-flex-grid-column>
    <wj-flex-grid-column binding="rate"></wj-flex-grid-column>
  </wj-flex-grid>

  <h2>
    Homogeneous hierarchy.</h2>
  <p>
    In this case, we set the <b>ChildItemsPath</b> property to a string ('checks').
    The result is an outline with one level of grouping, since only the top-level objects
    have a 'checks' collection.</p>
  <wj-flex-grid items-source="workers" child-items-path="checks">
    <wj-flex-grid-column binding="name"></wj-flex-grid-column>
    <wj-flex-grid-column binding="hours"></wj-flex-grid-column>
    <wj-flex-grid-column binding="rate"></wj-flex-grid-column>
  </wj-flex-grid>

  <h2>
    Heterogeneous hierarchy.</h2>
  <p>
    In this case, we set the <b>ChildItemsPath</b> property to an array
    (['checks', 'earnings']). The result is an outline with two levels of grouping.</p>
  <wj-flex-grid items-source="workers" xinitialized="init(s,e)" child-items-path="['checks','earnings']">
    <wj-flex-grid-column binding="name"></wj-flex-grid-column>
    <wj-flex-grid-column binding="hours"></wj-flex-grid-column>
    <wj-flex-grid-column binding="rate"></wj-flex-grid-column>
 ...

CSS

.wj-flexgrid {
  max-height: 250px;
  margin-top: 10px;
}

.wj-flexgrid .wj-cell.wj-new {
  color: #808080;
  font-style: italic;
}

JavaScript

// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);

// controller
app.controller('appCtrl', function($scope) {
  $scope.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: 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 }
      ]
    }]
  }];

});