Menu as Value Pickers

The Menu control in this sample is used as a value picker. It extends the ComboBox control, which allows you to bind variables to the control's selectedValue property as you would with a ComboBox.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as input from '@grapecity/wijmo.input'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let valuePicker = new input.Menu('#valuePicker', { // update header to show current selection selectedIndexChanged: (sender) => { if (sender.selectedIndex > -1) { sender.header = `Tax: <b>${sender.selectedItem.header}</b>`; } }, // // populate menu after hooking up the selectedIndexChanged event displayMemberPath: 'header', selectedValuePath: 'value', itemsSource: [ { header: 'Exempt', value: 0 }, { header: '1%', value: 0.01 }, { header: '5%', value: 0.05 }, { header: '8.5%', value: 0.085 }, { header: '10%', value: 0.10 }, { header: '20%', value: 0.20 } ], selectedValue: 0.085 }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Menu Value Pickers</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="valuePicker"></div> </div> </body> </html> body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjInputModule } from '@grapecity/wijmo.angular2.input'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data = [ { header: 'Exempt', value: 0 }, { header: '1%', value: 0.01 }, { header: '5%', value: 0.05 }, { header: '8.5%', value: 0.085 }, { header: '10%', value: 0.10 }, { header: '20%', value: 0.20 } ]; } // @NgModule({ imports: [WjInputModule, BrowserModule], declarations: [AppComponent], 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 Menu Value Pickers</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-menu #menu [displayMemberPath]="'header'" [selectedValuePath]="'value'" [header]="menu.selectedItem ? 'Tax: <b>' + menu.selectedItem.header + '</b>' : menu.header" [itemsSource]="data" [selectedValue]="0.085"> </wj-menu> </div> body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <wj-menu displayMemberPath="header" selectedValuePath="value" :itemsSource="source" :selectedItem="selectedItem" :header="'Tax: <b>' + selectedItem.header + '</b>'" :selectedIndexChanged="selectedIndexChanged"> </wj-menu> </div> </template> <script> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.core'; import '@grapecity/wijmo.vue2.input'; let App = Vue.extend({ name: 'app', data: function() { let source = [ { header: 'Exempt', value: 0 }, { header: '1%', value: 0.01 }, { header: '5%', value: 0.05 }, { header: '8.5%', value: 0.085 }, { header: '10%', value: 0.10 }, { header: '20%', value: 0.20 } ]; let selectedItem = source[3]; // return { source, selectedItem }; }, methods: { selectedIndexChanged: function(sender){ if (sender.selectedIndex >= 0) { this.selectedItem = sender.selectedItem; } } } }) let vm = new Vue({ render: h => h(App) }).$mount('#app'); </script> <style> 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 Menu Value Pickers</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> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './app.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjInput from '@grapecity/wijmo.react.input'; // class App extends React.Component { constructor(props) { super(props); this._itemSource = [ { header: 'Exempt', value: 0 }, { header: '1%', value: 0.01 }, { header: '5%', value: 0.05 }, { header: '8.5%', value: 0.085 }, { header: '10%', value: 0.10 }, { header: '20%', value: 0.20 } ]; this.state = { selectedIndex: 3 }; } render() { let selectedItem = this._itemSource[this.state.selectedIndex]; return <div className="container-fluid"> <wjInput.Menu displayMemberPath="header" selectedValuePath="value" header={`Tax: <b>${selectedItem.header}</b>`} itemsSource={this._itemSource} selectedIndex={this.state.selectedIndex} selectedIndexChanged={this._selectedIndexChanged.bind(this)}> </wjInput.Menu> </div>; } _selectedIndexChanged(sender) { if (sender.selectedIndex >= 0) { this.setState({ selectedIndex: sender.selectedIndex }); } } } 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> body { margin-bottom: 24pt; }