動作

TreeViewコンテンツを定義するデータ連結プロパティに加えて、コントロールはその動作をカスタマイズするいくつかのプロパティを提供します。このサンプルは、これらのプロパティのいくつかの効果を示しています。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjCore from '@grapecity/wijmo'; import * as wjNav from '@grapecity/wijmo.nav'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // create the tree var theTree = new wjNav.TreeView('#theTree', { itemsSource: getData(), displayMemberPath: 'header', childItemsPath: 'items' }); theTree.selectedItem = theTree.itemsSource[0]; // create checkboxes for the main properties var props = [ { title: 'ドラッグを許可', value: 'allowDragging' }, { title: '自動的に折りたたみ', value: 'autoCollapse' }, { title: 'クリックで展開', value: 'expandOnClick' }, { title: 'アニメーション', value: 'isAnimated' }, { title: '読み取り専用', value: 'isReadOnly' }, { title: 'チェックボックス', value: 'showCheckboxes' }, ], host = document.getElementById('properties'); props.forEach(function (prop) { var el = wjCore.createElement(`<label><input id="${prop.value}" type="checkbox"> ${prop.title}</label>`, host); el.querySelector('input').checked = theTree[prop.value]; }); host.addEventListener('click', function (e) { if (e.target instanceof HTMLInputElement) { theTree[e.target.id] = e.target.checked; } }); // handle buttons document.getElementById('btnCollapse').addEventListener('click', function () { theTree.collapseToLevel(0); }); document.getElementById('btnExpand').addEventListener('click', function () { theTree.collapseToLevel(100000); }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo TreeView Main Properties</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 class="row"> <div class="col-xs-6"> <div id="properties"></div> <button id="btnCollapse" class="btn btn-default">すべて折りたたむ</button> <button id="btnExpand" class="btn btn-default">すべて展開</button> </div> <div class="col-xs-6"> <div id="theTree"> </div> </div> </div> </div> </body> </html> export function getData() { return [ { header: '親ノード 1', items: [ { header: '子ノード 1.1' }, { header: '子ノード 1.2' }, { header: '子ノード 1.3' } ] }, { header: '親ノード 2', items: [ { header: '子ノード 2.1' }, { header: '子ノード 2.2' } ] }, { header: '親ノード 3', items: [ { header: '子ノード 3.1' } ] } ]; } /* default trees on this sample */ .wj-treeview { height: 350px; border: 1px solid rgba(0,0,0,0.2); } .wj-combobox { width: 120px; } label { width: 160px; margin-bottom: 12px; } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjCore from '@grapecity/wijmo'; // import { Component, Inject, enableProdMode, NgModule, ViewChild, AfterViewInit } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjNavModule, WjTreeView } from '@grapecity/wijmo.angular2.nav'; import { DataService, TreeItem } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent implements AfterViewInit { @ViewChild('theTree') theTree: WjTreeView; data: TreeItem[]; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } // ngAfterViewInit() { var tree = this.theTree; tree.selectedItem = this.data[0]; // create checkboxes for the main properties var props = this.dataService.getOptions(), host = document.getElementById('properties'); props.forEach(function (prop) { var el = wjCore.createElement(`<label><input id="${prop.value}" type="checkbox"> ${prop.title}</label>`, host); el.querySelector('input').checked = tree[prop.value]; }); host.addEventListener('click', function (e: MouseEvent) { if (e.target instanceof HTMLInputElement) { tree[e.target.id] = e.target.checked; } }) } // onTreeCollapsedLoadedItems() { this.theTree.collapseToLevel(0); } // onTreeExpandedLoadedItems() { this.theTree.collapseToLevel(100000); } } // @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"> <div class="row"> <div class="col-xs-6"> <div id="properties"></div> <button id="btnCollapse" class="btn btn-default" (click)="onTreeCollapsedLoadedItems()">すべて折りたたむ</button> <button id="btnExpand" class="btn btn-default" (click)="onTreeExpandedLoadedItems()">すべて展開</button> </div> <div class="col-xs-6"> <wj-tree-view #theTree [itemsSource]="data" [displayMemberPath]="'header'" [childItemsPath]="'items'"> </wj-tree-view> </div> </div> </div> import { Injectable } from '@angular/core'; export class TreeItem { header: string; items?: TreeItem[] } @Injectable() export class DataService { getData(): TreeItem[] { return [ { header: '親ノード 1', items: [ { header: '子ノード 1.1' }, { header: '子ノード 1.2' }, { header: '子ノード 1.3' }] }, { header: '親ノード 2', items: [ { header: '子ノード 2.1' }, { header: '子ノード 2.2' }] }, { header: '親ノード 3', items: [ { header: '子ノード 3.1' }] } ]; } getOptions(): any[] { return [ { title: 'ドラッグを許可', value: 'allowDragging' }, { title: '自動的に折りたたみ', value: 'autoCollapse' }, { title: 'クリックで展開', value: 'expandOnClick' }, { title: 'アニメーション', value: 'isAnimated' }, { title: '読み取り専用', value: 'isReadOnly' }, { title: 'チェックボックス', value: 'showCheckboxes' }, ]; } } /* default trees on this sample */ .wj-treeview { height: 350px; border: 1px solid rgba(0,0,0,0.2); } .wj-combobox { width: 120px; } label { width: 160px; margin-bottom: 12px; } body { margin-bottom: 24pt; } 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 * as wjCore from '@grapecity/wijmo'; import { getData } from './data'; class App extends React.Component { constructor(props) { super(props); this.state = getData(); } render() { return (<div className="container-fluid"> <div className="row"> <div className="col-xs-6"> <div id="properties"></div> <button id="btnCollapse" className="btn btn-default" onClick={this.onTreeCollapsedLoadedItems.bind(this)}>すべて折りたたむ</button> <button id="btnExpand" className="btn btn-default" onClick={this.onTreeExpandedLoadedItems.bind(this)}>すべて展開</button> </div> <div className="col-xs-6"> <wjNav.TreeView itemsSource={this.state} displayMemberPath="header" childItemsPath="items" initialized={(control) => this._treeView = control}> </wjNav.TreeView> </div> </div> </div>); } onTreeCollapsedLoadedItems(s, e) { this._treeView.collapseToLevel(0); } onTreeExpandedLoadedItems(s, e) { this._treeView.collapseToLevel(100000); } componentDidMount() { var prps = 'allowDragging,autoCollapse,expandOnClick,isAnimated,isReadOnly,showCheckboxes'.split(',').map((value, index) => { return { value: value, title: 'ドラッグを許可,自動的に折りたたみ,クリックで展開,アニメーション,読み取り専用,チェックボックス'.split(',')[index] }; }), host = document.getElementById('properties'), tpl = '<label><input id="{prop}" type="checkbox"> {prop}</label>'; prps.forEach((prop) => { var el = wjCore.createElement(`<label><input id="${prop.value}" type="checkbox"> ${prop.title}</label>`, host); el.querySelector('input').checked = this._treeView[prop.value]; }); host.addEventListener('click', (e) => { if (e.target instanceof HTMLInputElement) { this._treeView[e.target.id] = e.target.checked; } }); } } 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> .container-fluid .wj-treeview { height: 350px; border: 1px solid rgba(0,0,0,0.2); } .container-fluid .wj-combobox { width: 120px; } label { width: 160px; margin-bottom: 12px; } body { margin-bottom: 24pt; } export function getData() { return [ { header: '親ノード 1', items: [ { header: '子ノード 1.1' }, { header: '子ノード 1.2' }, { header: '子ノード 1.3' } ] }, { header: '親ノード 2', items: [ { header: '子ノード 2.1' }, { header: '子ノード 2.2' } ] }, { header: '親ノード 3', items: [ { header: '子ノード 3.1' } ] } ]; } <template> <div class="container-fluid"> <div class="row"> <div class="col-xs-6"> <div id="properties"></div> <button id="btnCollapse" class="btn btn-default" v-on:click="onTreeCollapsedLoadedItems">すべて折りたたむ</button> <button id="btnExpand" class="btn btn-default" v-on:click="onTreeExpandedLoadedItems">すべて展開</button> </div> <div class="col-xs-6"> <wj-tree-view :items-source="data" displayMemberPath="header" childItemsPath="items" :initialized="initTreeView"> </wj-tree-view> </div> </div> </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'; var treeView = null; new Vue({ el: '#app', data: function () { return { data: getData() } }, methods:{ initTreeView: function(ctl){ treeView = ctl; }, onTreeCollapsedLoadedItems: function(s, e){ treeView.collapseToLevel(0); }, onTreeExpandedLoadedItems: function(s, e){ treeView.collapseToLevel(100000); } }, mounted: function(){ var props = 'allowDragging,autoCollapse,expandOnClick,isAnimated,isReadOnly,showCheckboxes'.split(',').map((value, index) => { return { value: value, title: 'ドラッグを許可,自動的に折りたたみ,クリックで展開,アニメーション,読み取り専用,チェックボックス'.split(',')[index] } }), host = document.getElementById('properties'); props.forEach(function (prop) { var el = wjCore.createElement(`<label><input id="${prop.value}" type="checkbox"> ${prop.title}</label>`, host); el.querySelector('input').checked = treeView[prop.value]; }); host.addEventListener('click', function (e) { if (e.target instanceof HTMLInputElement) { treeView[e.target.id] = e.target.checked; } }); } }) </script> <style> .container-fluid .wj-treeview { height: 350px; border: 1px solid rgba(0,0,0,0.2); } .container-fluid .wj-combobox { width: 120px; } label { width: 160px; margin-bottom: 12px; } 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 Wijmo TreeView Main Properties</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 [ { header: '親ノード 1', items: [ { header: '子ノード 1.1' }, { header: '子ノード 1.2' }, { header: '子ノード 1.3' }] }, { header: '親ノード 2', items: [ { header: '子ノード 2.1' }, { header: '子ノード 2.2' }] }, { header: '親ノード 3', items: [ { header: '子ノード 3.1' }] } ]; }