Unbound Tree Grids

If you prefer to work in unbound mode, you can still build trees by adding rows and columns in code.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjGrid from '@grapecity/wijmo.grid'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // // 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: 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 } ] }] }]; // // unbound workers tree var uwt = new wjGrid.FlexGrid('#workersGrid', { headersVisibility: 'Column', selectionMode: 'Row', beginningEdit: function (s, e) { var value = e.panel.getCellData(e.row, e.col); if (value == null) { e.cancel = true; // can't edit! } } }); // // add columns uwt.columns.push(new wjGrid.Column({ header: 'Name' })); uwt.columns.push(new wjGrid.Column({ header: 'Hours', dataType: 'Number', format: 'n2' })); uwt.columns.push(new wjGrid.Column({ header: 'Rate', dataType: 'Number', format: 'n2' })); // // add rows for (var w = 0; w < workers.length; w++) { // // add worker var worker = workers[w]; var row = new wjGrid.GroupRow(); row.dataItem = worker; row.isReadOnly = false; row.level = 0; uwt.rows.push(row); uwt.setCellData(row.index, 0, worker.name); for (var c = 0; c < worker.checks.length; c++) { // // add check var check = worker.checks[c]; row = new wjGrid.GroupRow(); row.dataItem = check; row.isReadOnly = false; row.level = 1; uwt.rows.push(row); uwt.setCellData(row.index, 0, check.name); for (var e = 0; e < check.earnings.length; e++) { // // add earning var earning = check.earnings[e]; row = new wjGrid.GroupRow(); row.dataItem = earning; row.isReadOnly = false; row.level = 2; uwt.rows.push(row); uwt.setCellData(row.index, 0, earning.name); uwt.setCellData(row.index, 1, earning.hours); uwt.setCellData(row.index, 2, earning.rate); // } } } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Unbound Tree Grid</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div id="workersGrid"></div> </div> </body> </html> .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; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as wjGrid from '@grapecity/wijmo.grid'; import { Component, Inject, enableProdMode, NgModule, ViewChild, AfterViewInit } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridModule } from '@grapecity/wijmo.angular2.grid'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent implements AfterViewInit { @ViewChild('workersGrid') workersGrid: wjGrid.FlexGrid; // DataSvc will be passed by derived classes constructor(@Inject(DataService) private dataService: DataService) { } // ngAfterViewInit() { let workers = this.dataService.getWorkers(); // add columns this.workersGrid.columns.push(new wjGrid.Column({ header: 'Name' })); this.workersGrid.columns.push(new wjGrid.Column({ header: 'Hours', dataType: 'Number', format: 'n2' })); this.workersGrid.columns.push(new wjGrid.Column({ header: 'Rate', dataType: 'Number', format: 'n2' })); // // add rows for (var w = 0; w < workers.length; w++) { // // add worker var worker = workers[w]; var row = new wjGrid.GroupRow(); row.dataItem = worker; row.isReadOnly = false; row.level = 0; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, worker.name); for (var c = 0; c < worker.checks.length; c++) { // // add check var check = worker.checks[c]; row = new wjGrid.GroupRow(); row.dataItem = check; row.isReadOnly = false; row.level = 1; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, check.name); for (var e = 0; e < check.earnings.length; e++) { // // add earning var earning = check.earnings[e]; row = new wjGrid.GroupRow(); row.dataItem = earning; row.isReadOnly = false; row.level = 2; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, earning.name); this.workersGrid.setCellData(row.index, 1, earning.hours); this.workersGrid.setCellData(row.index, 2, earning.rate); // } } } } // onBeginningEdit(flexGird: wjGrid.FlexGrid, e: wjGrid.FormatItemEventArgs) { var value = e.panel.getCellData(e.row, e.col, true); if (value == null) { e.cancel = true; // can't edit! } } } //\\ @NgModule({ imports: [WjGridModule, BrowserModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Unbound Tree Grid</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <wj-flex-grid #workersGrid [headersVisibility]="'Column'" [selectionMode]="'Row'" (beginningEdit)="onBeginningEdit(workersGrid, $event)"> </wj-flex-grid> </div> import { Injectable } from '@angular/core'; @Injectable() export class DataService { getWorkers() { return [{ 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 } ] }] }]; } } .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; } <template> <div class="container-fluid"> <wj-flex-grid headers-visibility="Column" selection-mode="Row" :beginningEdit="onBeginningEdit" :initialized="initialGrid"> </wj-flex-grid> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import Vue from "vue"; import * as wjcGrid from '@grapecity/wijmo.grid'; import "@grapecity/wijmo.vue2.grid"; import { getWorkers } from "./data"; new Vue({ el: "#app", mounted: function() { let workers = getWorkers(); // add columns this.workersGrid.columns.push(new wjcGrid.Column({ header: 'Name' })); this.workersGrid.columns.push(new wjcGrid.Column({ header: 'Hours', dataType: 'Number', format: 'n2' })); this.workersGrid.columns.push(new wjcGrid.Column({ header: 'Rate', dataType: 'Number', format: 'n2' })); // add rows for (let w = 0; w < workers.length; w++) { // add worker let worker = workers[w]; let row = new wjcGrid.GroupRow(); row.dataItem = worker; row.isReadOnly = false; row.level = 0; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, worker.name); for (let c = 0; c < worker.checks.length; c++) { // add check let check = worker.checks[c]; row = new wjcGrid.GroupRow(); row.dataItem = check; row.isReadOnly = false; row.level = 1; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, check.name); for (let e = 0; e < check.earnings.length; e++) { // add earning let earning = check.earnings[e]; row = new wjcGrid.GroupRow(); row.dataItem = earning; row.isReadOnly = false; row.level = 2; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, earning.name); this.workersGrid.setCellData(row.index, 1, earning.hours); this.workersGrid.setCellData(row.index, 2, earning.rate); } } } }, methods: { initialGrid(grid) { this.workersGrid = grid; }, onBeginningEdit(flexGird, e) { let value = e.panel.getCellData(e.row, e.col, true); if (value == null) { e.cancel = true; // can't edit! } } } }); </script> <style> .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; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Unbound Tree Grid</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> export function getWorkers() { return [{ 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 } ] }] }]; } import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import "./app.css"; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjcGrid from "@grapecity/wijmo.react.grid"; import * as wjGrid from "@grapecity/wijmo.grid"; import { getWorkers } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getWorkers(), rowCountText: '' }; } render() { return <div className="container-fluid"> <wjcGrid.FlexGrid headersVisibility="Column" selectionMode="Row" beginningEdit={this.onBeginningEdit.bind(this)} initialized={this.initialGrid.bind(this)}> </wjcGrid.FlexGrid> </div>; } componentDidMount() { let workers = getWorkers(); // add columns this.workersGrid.columns.push(new wjGrid.Column({ header: 'Name' })); this.workersGrid.columns.push(new wjGrid.Column({ header: 'Hours', dataType: 'Number', format: 'n2' })); this.workersGrid.columns.push(new wjGrid.Column({ header: 'Rate', dataType: 'Number', format: 'n2' })); // add rows for (let w = 0; w < workers.length; w++) { // add worker let worker = workers[w]; let row = new wjGrid.GroupRow(); row.dataItem = worker; row.isReadOnly = false; row.level = 0; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, worker.name); for (let c = 0; c < worker.checks.length; c++) { // add check let check = worker.checks[c]; row = new wjGrid.GroupRow(); row.dataItem = check; row.isReadOnly = false; row.level = 1; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, check.name); for (let e = 0; e < check.earnings.length; e++) { // add earning let earning = check.earnings[e]; row = new wjGrid.GroupRow(); row.dataItem = earning; row.isReadOnly = false; row.level = 2; this.workersGrid.rows.push(row); this.workersGrid.setCellData(row.index, 0, earning.name); this.workersGrid.setCellData(row.index, 1, earning.hours); this.workersGrid.setCellData(row.index, 2, earning.rate); } } } } initialGrid(grid) { this.workersGrid = grid; } onBeginningEdit(flexGird, e) { let value = e.panel.getCellData(e.row, e.col, true); if (value == null) { e.cancel = true; // can't edit! } } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Chart Overview</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> .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; } export function getWorkers() { return [{ 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 } ] }] }]; }