複数選択

このサンプルでは、ツリービューのドロップダウンリストに複数のアイテムを同時に選択する場合、親ノードと子ノードの依存関係や値の構成などの設定を示しています。

コンボコントロールでは、ドロップダウンリストの複数のアイテムを同時に選択する場合、親ノードの選択可否や選択値の構成などを設定できます。 親ノードの選択可否 selectableNodeTypeプロパティを利用することで、複数選択の時にドロップダウンリストにある親ノードが選択できるかどうかを設定できます。設定できる値(TreeViewNodeType列挙体)は、以下の通りです。既定値はAllです。 TreeViewNodeTypeの値 説明 All 親ノードが選択可能 Leaf 親ノードが選択不可 設定例は以下の通りです。 親ノードと子ノードの依存関係 flatプロパティをtrueに設定すると、親ノードを選択するても配下の子ノードが自動的に選択されないことを設定できます。設定例は以下の通りです。 選択値の構成 コンボコントロールのドロップダウンリストで複数選択を有効にした場合はvalueConsistsOfプロパティを使用して、親ノードにあるすべての子ノードが選択される場合の値の構成を設定することができます。valueConsistsOfプロパティに設定できる値は次のとおりで、既定値はValueConsistsOf.NonLeafPriorityです。 ValueConsistsOfの値 説明 NonLeafPriority 選択値は親ノードで構成される All 選択値は親ノードと子ノードの両方で構成される LeafPriority 選択値は子ノードで構成される 設定例は以下の通りです。
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"; InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern; const App = () => { const products = [{ product: 'ジュース', children: [{ product: 'ストレートジュース', children: ['果汁100%オレンジ', '果汁100%グレープ', '果汁100%レモン', '果汁100%ピーチ'], expanded: true, }, { product: 'ブレンドジュース', children: ['オレンジブレンド', 'グレープブレンド', 'レモンブレンド', 'ピーチブレンド'] } ], expanded: true, }, { product: 'コーヒー', children: ['コーヒーマイルド', 'コーヒービター'], }]; let gcComboBox1 = null; const gcComboBox1Config = { items: products, dropDownType: InputMan.ComboDropDownType.Tree, isMultiSelect: true, displayMemberPath: 'product', checkOnClick: true, width: 300, allowDropDownResize: true, }; const gcComboBox2Config = { items: products, dropDownType: InputMan.ComboDropDownType.Tree, isMultiSelect: true, displayMemberPath: 'product', dropDownTreeConfig: { selectableNodeType: InputMan.TreeViewNodeType.Leaf, }, checkOnClick: true, width: 300, allowDropDownResize: true, }; const gcComboBox3Config = { items: products, dropDownType: InputMan.ComboDropDownType.Tree, isMultiSelect: true, displayMemberPath: 'product', dropDownTreeConfig: { flat: true, }, checkOnClick: true, width: 300, allowDropDownResize: true, }; const valueConsistsOf = [ InputMan.ValueConsistsOf.NonLeafPriority, InputMan.ValueConsistsOf.All, InputMan.ValueConsistsOf.LeafPriority, ]; const onInitialized = (gcComboBox) => { gcComboBox1 = gcComboBox; }; const onValueConsistsOfChanged = (e) => { gcComboBox1.dropDownTree.valueConsistsOf = valueConsistsOf[e.target.selectedIndex]; }; return ( <div> 遅延読み込み<br/> <div class="flexbox"> <div> デフォルト<br/> <GcComboBox onInitialized={onInitialized} items={gcComboBox1Config.items} dropDownType={gcComboBox1Config.dropDownType} isMultiSelect={gcComboBox1Config.isMultiSelect} displayMemberPath={gcComboBox1Config.displayMemberPath} checkOnClick={gcComboBox1Config.checkOnClick} width={gcComboBox1Config.width} allowDropDownResize={gcComboBox1Config.allowDropDownResize} /> </div> <div> 親ノードが選択不可<br/> <GcComboBox items={gcComboBox2Config.items} dropDownType={gcComboBox2Config.dropDownType} isMultiSelect={gcComboBox2Config.isMultiSelect} displayMemberPath={gcComboBox2Config.displayMemberPath} dropDownTreeConfig={gcComboBox2Config.dropDownTreeConfig} checkOnClick={gcComboBox2Config.checkOnClick} width={gcComboBox2Config.width} allowDropDownResize={gcComboBox2Config.allowDropDownResize} /> </div> </div> <br/><br/><br/><br/><br/><br/> <table class="sample"> <tr> <th>選択値の構成</th> <td> <select id="valueConsistsOf" onChange={onValueConsistsOfChanged}> <option selected>親ノードのみ</option> <option>親ノードと子ノード</option> <option>子ノードのみ</option> </select> </td> </tr> </table> <h4>親ノードを選択しても、子ノードは自動的には選択されません。</h4> <GcComboBox items={gcComboBox3Config.items} dropDownType={gcComboBox3Config.dropDownType} isMultiSelect={gcComboBox3Config.isMultiSelect} displayMemberPath={gcComboBox3Config.displayMemberPath} dropDownTreeConfig={gcComboBox3Config.dropDownTreeConfig} checkOnClick={gcComboBox3Config.checkOnClick} width={gcComboBox3Config.width} allowDropDownResize={gcComboBox3Config.allowDropDownResize} /> </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>
(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);