Heterogeneous Data

To view heterogeneous data, set the displayMemberPath and childItemsPath properties to arrays in the TreeView control. The sample below is bound to a list of continent items, each with a countries member that contains a list of country items with a cities member.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjNav from '@grapecity/wijmo.nav'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // // create the tree var tree = new wjNav.TreeView('#theTree', { itemsSource: getData(), displayMemberPath: 'continent,country,city'.split(','), childItemsPath: 'countries,cities'.split(',') }); // } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Sample</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="theTree"></div> </div> </body> </html> // get the data export function getData() { return [ { continent: 'Africa', countries: [ { country: 'Algeria', cities: [ { city: 'Algiers' }, { city: 'Oran' }, { city: 'Constantine' } ] }, { country: 'Angola', cities: [ { city: 'Luanda' }, { city: 'Ambriz' }, { city: 'Bailundo' } ] }, { country: 'Benin', cities: [ { city: 'Porto Novo' }, { city: 'Cotonou' }, { city: 'Parakou' } ] }, { country: 'Botswana', cities: [ { city: 'Gaborone' }, { city: 'Francistown' }, { city: 'Molepolole' } ] }, ] }, { continent: 'Asia', countries: [ { country: 'Afghanistan', cities: [ { city: 'Kabul' }, { city: 'Kandahar' }, { city: 'Herat' } ] }, { country: 'Armenia', cities: [ { city: 'Yerevan' }, { city: 'Gyumri' }, { city: 'Vanadzor' } ] }, { country: 'Azerbaijan', cities: [ { city: 'Baku' }, { city: 'Agjabadi' }, { city: 'Astara' } ] }, { country: 'Bahrain', cities: [ { city: 'Manama' }, { city: 'Riffa' }, { city: 'Sitra' } ] }, ] }, { continent: 'Europe', countries: [ { country: 'Albania', cities: [ { city: 'Tirana' }, { city: 'Elbasan' }, { city: 'Fier' } ] }, { country: 'Andorra', cities: [ { city: 'Andorra la Vieja' }, { city: 'Canillo' }, { city: 'Encamp' } ] }, { country: 'Austria', cities: [ { city: 'Vienna' }, { city: 'Salzburg' }, { city: 'Graz' } ] }, { country: 'Belarus', cities: [ { city: 'Minsk' }, { city: 'Barysaw' }, { city: 'Slutsk' } ] }, ] }, { continent: 'America', countries: [ { country: 'Canada', cities: [ { city: 'Ottawa' }, { city: 'Toronto' }, { city: 'Vancouver' } ] }, { country: 'United States', cities: [ { city: 'Washington' }, { city: 'New York' }, { city: 'Pittsburgh' } ] }, { country: 'Mexico', cities: [ { city: 'Mexico City' }, { city: 'Acapulco' }, { city: 'San Jose' } ] }, { country: 'Belize', cities: [ { city: 'Belmopan' }, { city: 'Dangriga' }, { city: 'Belize City' } ] }, ] }, { continent: 'Ocenania', countries: [ { country: 'Australia', cities: [ { city: 'Canberra' }, { city: 'Sydney' }, { city: 'Melbourne' } ] }, { country: 'New Zealand', cities: [ { city: 'Wellington' }, { city: 'Christchurch' }, { city: 'Auckland' } ] }, { country: 'Fiji', cities: [ { city: 'Suva' }, { city: 'Labasa' }, { city: 'Nasinu' } ] }, { country: 'Vanuatu', cities: [ { city: 'Port Vila' }, { city: 'Forari' }, { city: 'Etate' } ] }, ] }, ]; } /* default trees on this sample */ .wj-treeview { display:block; //height: 350px; font-size: 120%; margin-bottom: 8px; padding: 6px; background: #f0f0f0; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjNavModule } from '@grapecity/wijmo.angular2.nav'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; path = 'continent,country,city'.split(','); items = 'countries,cities'.split(','); // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } } // @NgModule({ imports: [WjNavModule, 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 TreeView Hosting GCControls</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-tree-view [itemsSource]="data" [displayMemberPath]="path" [childItemsPath]="items"></wj-tree-view> </div> import { Injectable } from '@angular/core'; @Injectable() export class DataService { getData() { return [ { continent: 'Africa', countries: [ { country: 'Algeria', cities: [ { city: 'Algiers' }, { city: 'Oran' }, { city: 'Constantine' } ] }, { country: 'Angola', cities: [ { city: 'Luanda' }, { city: 'Ambriz' }, { city: 'Bailundo' } ] }, { country: 'Benin', cities: [ { city: 'Porto Novo' }, { city: 'Cotonou' }, { city: 'Parakou' } ] }, { country: 'Botswana', cities: [ { city: 'Gaborone' }, { city: 'Francistown' }, { city: 'Molepolole' } ] }, ] }, { continent: 'Asia', countries: [ { country: 'Afghanistan', cities: [ { city: 'Kabul' }, { city: 'Kandahar' }, { city: 'Herat' } ] }, { country: 'Armenia', cities: [ { city: 'Yerevan' }, { city: 'Gyumri' }, { city: 'Vanadzor' } ] }, { country: 'Azerbaijan', cities: [ { city: 'Baku' }, { city: 'Agjabadi' }, { city: 'Astara' } ] }, { country: 'Bahrain', cities: [ { city: 'Manama' }, { city: 'Riffa' }, { city: 'Sitra' } ] }, ] }, { continent: 'Europe', countries: [ { country: 'Albania', cities: [ { city: 'Tirana' }, { city: 'Elbasan' }, { city: 'Fier' } ] }, { country: 'Andorra', cities: [ { city: 'Andorra la Vieja' }, { city: 'Canillo' }, { city: 'Encamp' } ] }, { country: 'Austria', cities: [ { city: 'Vienna' }, { city: 'Salzburg' }, { city: 'Graz' } ] }, { country: 'Belarus', cities: [ { city: 'Minsk' }, { city: 'Barysaw' }, { city: 'Slutsk' } ] }, ] }, { continent: 'America', countries: [ { country: 'Canada', cities: [ { city: 'Ottawa' }, { city: 'Toronto' }, { city: 'Vancouver' } ] }, { country: 'United States', cities: [ { city: 'Washington' }, { city: 'New York' }, { city: 'Pittsburgh' } ] }, { country: 'Mexico', cities: [ { city: 'Mexico City' }, { city: 'Acapulco' }, { city: 'San Jose' } ] }, { country: 'Belize', cities: [ { city: 'Belmopan' }, { city: 'Dangriga' }, { city: 'Belize City' } ] }, ] }, { continent: 'Ocenania', countries: [ { country: 'Australia', cities: [ { city: 'Canberra' }, { city: 'Sydney' }, { city: 'Melbourne' } ] }, { country: 'New Zealand', cities: [ { city: 'Wellington' }, { city: 'Christchurch' }, { city: 'Auckland' } ] }, { country: 'Fiji', cities: [ { city: 'Suva' }, { city: 'Labasa' }, { city: 'Nasinu' } ] }, { country: 'Vanuatu', cities: [ { city: 'Port Vila' }, { city: 'Forari' }, { city: 'Etate' } ] }, ] }, ]; } } /* default trees on this sample */ .wj-treeview { display:block; /*height: 350px;*/ font-size: 120%; margin-bottom: 8px; padding: 6px; background: #f0f0f0; box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); } body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <wj-tree-view :itemsSource="data" :displayMemberPath="path" :childItemsPath="items"></wj-tree-view> </div> </template> <script> import "bootstrap.css"; import "@grapecity/wijmo.styles/wijmo.css"; import Vue from "vue"; import "@grapecity/wijmo.vue2.nav"; import * as wjCore from "@grapecity/wijmo"; import { getData } from "./data"; let App = Vue.extend({ name: "app", data: function() { return { data: getData(), path: "continent,country,city".split(","), items: "countries,cities".split(",") }; } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> /* default trees on this sample */ .container-fluid .wj-treeview { display: block; font-size: 120%; margin-bottom: 8px; padding: 6px; background: #f0f0f0; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); } body { margin-bottom: 24pt; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Sample</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 getData() { return [ { continent: 'Africa', countries: [ { country: 'Algeria', cities: [ { city: 'Algiers' }, { city: 'Oran' }, { city: 'Constantine' } ] }, { country: 'Angola', cities: [ { city: 'Luanda' }, { city: 'Ambriz' }, { city: 'Bailundo' } ] }, { country: 'Benin', cities: [ { city: 'Porto Novo' }, { city: 'Cotonou' }, { city: 'Parakou' } ] }, { country: 'Botswana', cities: [ { city: 'Gaborone' }, { city: 'Francistown' }, { city: 'Molepolole' } ] }, ] }, { continent: 'Asia', countries: [ { country: 'Afghanistan', cities: [ { city: 'Kabul' }, { city: 'Kandahar' }, { city: 'Herat' } ] }, { country: 'Armenia', cities: [ { city: 'Yerevan' }, { city: 'Gyumri' }, { city: 'Vanadzor' } ] }, { country: 'Azerbaijan', cities: [ { city: 'Baku' }, { city: 'Agjabadi' }, { city: 'Astara' } ] }, { country: 'Bahrain', cities: [ { city: 'Manama' }, { city: 'Riffa' }, { city: 'Sitra' } ] }, ] }, { continent: 'Europe', countries: [ { country: 'Albania', cities: [ { city: 'Tirana' }, { city: 'Elbasan' }, { city: 'Fier' } ] }, { country: 'Andorra', cities: [ { city: 'Andorra la Vieja' }, { city: 'Canillo' }, { city: 'Encamp' } ] }, { country: 'Austria', cities: [ { city: 'Vienna' }, { city: 'Salzburg' }, { city: 'Graz' } ] }, { country: 'Belarus', cities: [ { city: 'Minsk' }, { city: 'Barysaw' }, { city: 'Slutsk' } ] }, ] }, { continent: 'America', countries: [ { country: 'Canada', cities: [ { city: 'Ottawa' }, { city: 'Toronto' }, { city: 'Vancouver' } ] }, { country: 'United States', cities: [ { city: 'Washington' }, { city: 'New York' }, { city: 'Pittsburgh' } ] }, { country: 'Mexico', cities: [ { city: 'Mexico City' }, { city: 'Acapulco' }, { city: 'San Jose' } ] }, { country: 'Belize', cities: [ { city: 'Belmopan' }, { city: 'Dangriga' }, { city: 'Belize City' } ] }, ] }, { continent: 'Ocenania', countries: [ { country: 'Australia', cities: [ { city: 'Canberra' }, { city: 'Sydney' }, { city: 'Melbourne' } ] }, { country: 'New Zealand', cities: [ { city: 'Wellington' }, { city: 'Christchurch' }, { city: 'Auckland' } ] }, { country: 'Fiji', cities: [ { city: 'Suva' }, { city: 'Labasa' }, { city: 'Nasinu' } ] }, { country: 'Vanuatu', cities: [ { city: 'Port Vila' }, { city: 'Forari' }, { city: 'Etate' } ] }, ] }, ]; } import './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjNav from '@grapecity/wijmo.react.nav'; import { getData } from './data'; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData(), path: "continent,country,city".split(","), items: "countries,cities".split(",") }; } render() { return (<div className="container-fluid"> <wjNav.TreeView itemsSource={this.state.data} displayMemberPath={this.state.path} childItemsPath={this.state.items}></wjNav.TreeView> </div>); } } 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>AutoComplete</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> /* default trees on this sample */ .container-fluid .wj-treeview { display: block; font-size: 120%; margin-bottom: 8px; padding: 6px; background: #f0f0f0; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); } body { margin-bottom: 24pt; } export function getData() { return [ { continent: 'Africa', countries: [ { country: 'Algeria', cities: [ { city: 'Algiers' }, { city: 'Oran' }, { city: 'Constantine' } ] }, { country: 'Angola', cities: [ { city: 'Luanda' }, { city: 'Ambriz' }, { city: 'Bailundo' } ] }, { country: 'Benin', cities: [ { city: 'Porto Novo' }, { city: 'Cotonou' }, { city: 'Parakou' } ] }, { country: 'Botswana', cities: [ { city: 'Gaborone' }, { city: 'Francistown' }, { city: 'Molepolole' } ] }, ] }, { continent: 'Asia', countries: [ { country: 'Afghanistan', cities: [ { city: 'Kabul' }, { city: 'Kandahar' }, { city: 'Herat' } ] }, { country: 'Armenia', cities: [ { city: 'Yerevan' }, { city: 'Gyumri' }, { city: 'Vanadzor' } ] }, { country: 'Azerbaijan', cities: [ { city: 'Baku' }, { city: 'Agjabadi' }, { city: 'Astara' } ] }, { country: 'Bahrain', cities: [ { city: 'Manama' }, { city: 'Riffa' }, { city: 'Sitra' } ] }, ] }, { continent: 'Europe', countries: [ { country: 'Albania', cities: [ { city: 'Tirana' }, { city: 'Elbasan' }, { city: 'Fier' } ] }, { country: 'Andorra', cities: [ { city: 'Andorra la Vieja' }, { city: 'Canillo' }, { city: 'Encamp' } ] }, { country: 'Austria', cities: [ { city: 'Vienna' }, { city: 'Salzburg' }, { city: 'Graz' } ] }, { country: 'Belarus', cities: [ { city: 'Minsk' }, { city: 'Barysaw' }, { city: 'Slutsk' } ] }, ] }, { continent: 'America', countries: [ { country: 'Canada', cities: [ { city: 'Ottawa' }, { city: 'Toronto' }, { city: 'Vancouver' } ] }, { country: 'United States', cities: [ { city: 'Washington' }, { city: 'New York' }, { city: 'Pittsburgh' } ] }, { country: 'Mexico', cities: [ { city: 'Mexico City' }, { city: 'Acapulco' }, { city: 'San Jose' } ] }, { country: 'Belize', cities: [ { city: 'Belmopan' }, { city: 'Dangriga' }, { city: 'Belize City' } ] }, ] }, { continent: 'Ocenania', countries: [ { country: 'Australia', cities: [ { city: 'Canberra' }, { city: 'Sydney' }, { city: 'Melbourne' } ] }, { country: 'New Zealand', cities: [ { city: 'Wellington' }, { city: 'Christchurch' }, { city: 'Auckland' } ] }, { country: 'Fiji', cities: [ { city: 'Suva' }, { city: 'Labasa' }, { city: 'Nasinu' } ] }, { country: 'Vanuatu', cities: [ { city: 'Port Vila' }, { city: 'Forari' }, { city: 'Etate' } ] }, ] }, ]; }