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 { value = 0.085; } // @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 header="Tax" [(value)]="value"> <wj-menu-item [value]="0">Exempt</wj-menu-item> <wj-menu-item [value]="0.01">1%</wj-menu-item> <wj-menu-item [value]="0.05">5%</wj-menu-item> <wj-menu-item [value]="0.085">8.5%</wj-menu-item> <wj-menu-item [value]="0.10">10%</wj-menu-item> <wj-menu-item [value]="0.20">20%</wj-menu-item> </wj-menu> </div> body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <wj-menu :value="tax" :header="'Tax'" :itemClicked="selectedTaxChanged"> <wj-menu-item :value="0">Exempt</wj-menu-item> <wj-menu-item :value="0.01">1%</wj-menu-item> <wj-menu-item :value="0.05">5%</wj-menu-item> <wj-menu-item :value="0.085">8.5%</wj-menu-item> <wj-menu-item :value="0.10">10%</wj-menu-item> <wj-menu-item :value="0.20">20%</wj-menu-item> </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() { const tax = 0.085; // return { tax }; }, methods: { selectedTaxChanged: function(sender){ if (sender.selectedValue) { this.tax = sender.selectedValue; } } } }) 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.state = { tax: 0.085 }; } render() { return <div className="container-fluid"> <wjInput.Menu header='Tax' value={this.state.tax} itemClicked={this.selectedTaxChanged.bind(this)}> <wjInput.MenuItem value={0}>Exempt</wjInput.MenuItem> <wjInput.MenuItem value={0.01}>1%</wjInput.MenuItem> <wjInput.MenuItem value={0.05}>5%</wjInput.MenuItem> <wjInput.MenuItem value={0.085}>8.5%</wjInput.MenuItem> <wjInput.MenuItem value={0.10}>10%</wjInput.MenuItem> <wjInput.MenuItem value={0.20}>20%</wjInput.MenuItem> </wjInput.Menu> </div>; } selectedTaxChanged(sender) { if (sender.selectedValue) { this.setState({ tax: sender.selectedValue }); } } } 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; }