概要と基本的な使い方

このサンプルでは、コンボコントロールのドロップダウンリストに階層データを設定する場合、データをツリーとして表示を設定しています。

コンボコントロールでは、データ項目が階層データの場合、ドロップダウンリストに表示する内容をツリーとして表示できます。 データ構造 コンボコントロールのドロップダウンリストをツリーとして表示するには、各データ項目が親子関係を持つように設定します。 以下のように、「children」プロパティを持つ「products」オブジェクトのデータをツリーとしてドロップダウンリストに表示します。「children」プロパティには「products」オブジェクトの配列が含まれ、さらに多くの「children」プロパティで子階層のデータを設定することができます。 ツリービューの設定 dropDownTypeプロパティを利用することで、コンボコントロールのドロップダウンリストの表示形式を設定できます。設定できる値(ComboDropDownType列挙体)は、以下の通りです。既定値はListです。 ComboDropDownTypeの値 説明 List ドロップダウンリストをリストとして表示する Tree ドロップダウンリストをツリーとして表示する ツリービューを有効にするには、dropDownTypeプロパティをComboDropDownType.Treeに設定します。 また、dropDownTreeConfigプロパティに、childrenMemberPathプロパティで子階層のコレクションを指定できます。既定値はchildrenです。 設定例は以下の通りです。 子階層の展開/折りたたみ表示 expandedMemberPathプロパティでドロップダウンリストを開く時に子階層を展開するかどうかを設定できます。既定値はexpandedです。expandedをtrueまたはfalseに設定することで、子階層の展開/折りたたみの表示を切り替えます。 ソート & フィルター & オートコンプリート ツリービューを設定したコンボコントロールはソート、フィルターとオートコンプリート機能をサポートします。フィルターを設定する場合、子ノードが入力内容にヒットすると、折りたたまれたノードが自動的に展開されます。
import * as React from "react"; import * as ReactDom from "react-dom"; import { GcComboBox } from "@mescius/inputman.react"; import '@mescius/inputman/CSS/gc.inputman-js.css'; import { InputMan } from "@mescius/inputman"; import { products, gcProducts } from './data' import "./styles.css"; InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern; const App = () => { const gcComboBox1Config = { items: products, width: 240, dropDownType: GC.InputMan.ComboDropDownType.Tree, displayMemberPath: 'product', } const gcComboBox2Config = { items: gcProducts, dropDownType: GC.InputMan.ComboDropDownType.Tree, itemHeight: 50, dropDownWidth: 540, width: 240, displayMemberPath: 'name', valueMemberPath: 'name', dropDownTreeConfig: { selectableNodeType: GC.InputMan.TreeViewNodeType.Leaf, itemTemplate: [ `<div class="template-parent-item"> <span>{!product}</span> </div>`, `<div class="template-item"> <div class="image"><img src="{!logo}"></div> <div class="names"><div class="name">{!name}</div><div class="category">{!category}</div></div> <div class="description">{!description}</div> </div>`, ], selectTemplate: (args) => { if ((args.item).type === 'parent') { return args.template[0]; } return args.template[1]; }, }, } return ( <div class="flexbox"> <div> 単純なリスト<br /> <GcComboBox items={gcComboBox1Config.items} width={gcComboBox1Config.width} dropDownType={gcComboBox1Config.dropDownType} displayMemberPath={gcComboBox1Config.displayMemberPath} > </GcComboBox> </div> <div> テンプレート<br /> <GcComboBox items={gcComboBox2Config.items} dropDownType={gcComboBox2Config.dropDownType} itemHeight={gcComboBox2Config.itemHeight} dropDownWidth={gcComboBox2Config.dropDownWidth} width={gcComboBox2Config.width} displayMemberPath={gcComboBox2Config.displayMemberPath} valueMemberPath={gcComboBox2Config.valueMemberPath} dropDownTreeConfig={gcComboBox2Config.dropDownTreeConfig} > </GcComboBox> </div> </div> ); }; ReactDom.render(<App />, document.getElementById("app"));
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>コンボコントロール - ツリービュー - 概要と基本的な使い方</title> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> window.onload = function() { System.import('./src/app'); } </script> </head> <body> <div id="app"></div> </body> </html>
export const products = [{ product: 'ジュース', children: [{ product: 'ストレートジュース', children: ['果汁100%オレンジ', '果汁100%グレープ', '果汁100%レモン', '果汁100%ピーチ'], expanded: true, }, { product: 'ブレンドジュース', children: ['オレンジブレンド', 'グレープブレンド', 'レモンブレンド', 'ピーチブレンド'] } ], expanded: true, }, { product: 'コーヒー', children: ['コーヒーマイルド', 'コーヒービター'], }]; export const gcProducts = [ { product: '帳票・ドキュメント関連製品', children: [ { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/AR.png', name: 'ActiveReports', category: '帳票・レポート', description: '日本仕様の帳票開発に必要な機能を搭載したコンポーネント', }, { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/SP.png', name: 'SPREAD', category: '表計算・グリッド', description: 'Excel風のビューと表計算機能を実現するUIコンポーネント', }, { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/DD.png', name: 'DioDocs', category: 'ドキュメントAPI', description: 'ドキュメントを生成、更新するAPIライブラリ', }, ], expanded: true, type: 'parent', }, { product: '入力・UI関連製品', children: [ { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/C1.png', name: 'ComponentOne', category: 'コンポーネントセット', description: 'Visual Studioで利用する.NET Framework用コンポーネント', }, { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/IM.png', name: 'InputMan', category: '入力支援', description: '快適な入力を実現する日本仕様入力コンポーネントセット', }, { logo: '$IMDEMOROOT$/ja/samples/comboBox/treeview/basic/img/MR.png', name: 'MultiRow', category: '多段明細', description: '1レコード複数行&日付表示に最適なグリッドコンポーネント', }, ], expanded: true, type: 'parent', }, ];
.template-parent-item { display: flex; align-items: center; font-weight: bold; height: 100%; } .template-item { height: 50px; display: flex; justify-content: center; align-items: center; } .template-item>* { margin: 0 5px; } .image { width: 40px; height: 40px; } .image img { width: 40px; } .names { width: 150px; } .name { font-size: 16px; font-weight: bold; color: #2676c0; } .description { width: 210px; white-space: normal; }
body { min-height: 350px; } [gcim-control-appearance="modern"] .viewport { line-height: 1.3; } [gcim-control-appearance="modern"] .template-parent-item { display: flex; align-items: center; font-weight: bold; height: 100%; } [gcim-control-appearance="modern"] .template-item { height: 50px; display: flex; justify-content: center; align-items: center; } [gcim-control-appearance="modern"] .template-item>* { margin: 0 5px; } [gcim-control-appearance="modern"] .image { width: 40px; height: 40px; } [gcim-control-appearance="modern"] .image img { width: 40px; } [gcim-control-appearance="modern"] .names { width: 150px; } [gcim-control-appearance="modern"] .name { font-size: 16px; font-weight: bold; color: #2676c0; } [gcim-control-appearance="modern"] .category { font-size: 12px; color: green; } [gcim-control-appearance="modern"] .description { width: 210px; white-space: normal; } [gcim-control-appearance="modern"] .list-item[selected="true"] .name, [gcim-control-appearance="modern"] .list-item[selected="true"] .category { color: white; } [gcim-control-appearance="modern"] .odd { background: aliceblue; }
(function (global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true, react: true, }, meta: { '*.css': { loader: 'css' }, }, paths: { // paths serve as alias 'npm:': 'node_modules/', }, // map tells the System loader where to look for things map: { '@mescius/inputman': 'npm:@mescius/inputman/index.js', '@mescius/inputman.react': 'npm:@mescius/inputman.react/GcInputMan.component.js', '@mescius/inputman/CSS': 'npm:@mescius/inputman/CSS', '@mescius/inputman.comment': 'npm:@mescius/inputman.comment/index.js', '@mescius/inputman.comment.react': 'npm:@mescius/inputman.comment.react/GcInputMan.component.js', '@mescius/inputman.comment/CSS': 'npm:@mescius/inputman.comment/CSS', '@mescius/inputman.richtexteditor': 'npm:@mescius/inputman.richtexteditor/index.js', '@mescius/inputman.richtexteditor.react': 'npm:@mescius/inputman.richtexteditor.react/GcInputMan.component.js', '@mescius/inputman.richtexteditor/CSS': 'npm:@mescius/inputman.richtexteditor/CSS', '@mescius/inputman.richtexteditor/JS/plugins/advlist': 'npm:@mescius/inputman.richtexteditor/JS/plugins/advlist/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/all': 'npm:@mescius/inputman.richtexteditor/JS/plugins/all/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/autosave': 'npm:@mescius/inputman.richtexteditor/JS/plugins/autosave/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/charmap': 'npm:@mescius/inputman.richtexteditor/JS/plugins/charmap/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/directionality': 'npm:@mescius/inputman.richtexteditor/JS/plugins/directionality/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/emoticons': 'npm:@mescius/inputman.richtexteditor/JS/plugins/emoticons/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/fullscreen': 'npm:@mescius/inputman.richtexteditor/JS/plugins/fullscreen/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/htmlcode': 'npm:@mescius/inputman.richtexteditor/JS/plugins/htmlcode/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/image': 'npm:@mescius/inputman.richtexteditor/JS/plugins/image/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/link': 'npm:@mescius/inputman.richtexteditor/JS/plugins/link/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/lists': 'npm:@mescius/inputman.richtexteditor/JS/plugins/lists/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/media': 'npm:@mescius/inputman.richtexteditor/JS/plugins/media/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/pagebreak': 'npm:@mescius/inputman.richtexteditor/JS/plugins/pagebreak/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/preview': 'npm:@mescius/inputman.richtexteditor/JS/plugins/preview/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/save': 'npm:@mescius/inputman.richtexteditor/JS/plugins/save/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/searchreplace': 'npm:@mescius/inputman.richtexteditor/JS/plugins/searchreplace/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/table': 'npm:@mescius/inputman.richtexteditor/JS/plugins/table/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/template': 'npm:@mescius/inputman.richtexteditor/JS/plugins/template/plugin.js', '@mescius/inputman.richtexteditor/JS/plugins/wordcount': 'npm:@mescius/inputman.richtexteditor/JS/plugins/wordcount/plugin.js', '@mescius/wijmo.styles': 'npm:@mescius/wijmo.styles', '@mescius/wijmo.cultures': 'npm:@mescius/wijmo.cultures', '@mescius/wijmo.input': 'npm:@mescius/wijmo.input/index.js', '@mescius/wijmo': 'npm:@mescius/wijmo/index.js', '@mescius/wijmo.grid': 'npm:@mescius/wijmo.grid/index.js', '@mescius/wijmo.nav': 'npm:@mescius/wijmo.nav/index.js', '@mescius/wijmo.interop.grid': 'npm:@mescius/wijmo.interop.grid/index.js', '@mescius/wijmo.react.grid': 'npm:@mescius/wijmo.react.grid/index.js', '@mescius/wijmo.react.base': 'npm:@mescius/wijmo.react.base/index.js', '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ja': 'npm:@mescius/spread-sheets-resources-ja/index.js', '@mescius/spread-sheets/styles': 'npm:@mescius/spread-sheets/styles', 'react': 'npm:react/umd/react.production.min.js', 'react-dom': 'npm:react-dom/umd/react-dom.production.min.js', 'react-dom/client': 'npm:react-dom/umd/react-dom.production.min.js', 'css': 'npm:systemjs-plugin-css/css.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js', }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'jsx', }, 'node_modules': { defaultExtension: 'js', }, }, }); })(this);