MultiSelect without $checked Property

The MultiSelect control requires a data member to determine whether items are selected. If one is not provided, the control adds a $checked property to the data items. You can prevent this by creating a dedicated itemsSource that contains objects with two properties: the original item and the checked member.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as input from '@grapecity/wijmo.input'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { var theMultiSelect = new input.MultiSelect('#theMultiSelect', { placeholder: 'Devices', displayMemberPath: 'item.name', checkedMemberPath: 'checked', itemsSource: getCheckableData(), checkedItemsChanged: (sender) => { let checkedItems = sender.checkedItems.map(checkableItem => checkableItem.item); document.querySelector('#checkedItems').textContent = checkedItems.length ? JSON.stringify(checkedItems) : ''; } }); // // create a data source with items and an extra checkable member function getCheckableData() { return getData().map(item => ({ item: item, checked: false })); } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity MultiSelect - no $checked property</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-5"> <div id="theMultiSelect"></div> </div> <div class="col-xs-7"> <p> <b>Checked Items:</b> </p> <p id="checkedItems"></p> </div> </div> </div> </body> </html> // list of country GDP and populations // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { return [ { "specific_type": "3067VIP10G-3G", "name": "My Crazy VIP", "generic_type": "vip10g", "id": 2, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.12", "port": 9700 } } }, { "specific_type": "EXE", "name": "My Crazy EXE", "generic_type": "exe", "id": 3, "model": "EXE", "properties": { "nports": 1152, "addr2": { "ip": null, "port": 9671 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 9671 } } }, { "specific_type": "3067VIP10G-3G", "name": "Another VIP", "generic_type": "vip10g", "id": 4, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.1", "port": 9700 } } }, { "specific_type": "570IPG-3G18-SFPP12", "name": "My Crazy IPG", "generic_type": "ipg", "id": 1, "model": "570IPG-3G18-SFPP12", "properties": { "in_band_control": { "ibctrl1": { "tally_port": 6578, "sfp": 1, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 }, "enabled": false, "ibctrl2": { "tally_port": 6578, "sfp": 3, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 } }, "port_properties": { "sdi8": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi9": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi6": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi7": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi4": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi5": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi2": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi3": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi1": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi14": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi15": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi16": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi17": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi10": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi11": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi12": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi13": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi18": { "rx_sfp": "Dynamic", "direction": "In" } }, "addr2": { "ip": null, "port": 161 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 161 } } } ]; } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as input from '@grapecity/wijmo.input'; // import { Component, enableProdMode, NgModule, Inject } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjInputModule } from '@grapecity/wijmo.angular2.input'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any; // constructor(@Inject(DataService) private dataService: DataService) { // create a data source with items and an extra checkable member this.data = dataService.getData().map(item => ({ item: item, checked: false })); } // getCheckedItems(ctrl: input.MultiSelect): string { let items = ctrl.checkedItems.map(checkableItem => checkableItem.item); return JSON.stringify(items); } } // @NgModule({ imports: [WjInputModule, 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 MultiSelect - no $checked property</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-5"> <wj-multi-select #theMultiSelect [placeholder]="'Devices'" [displayMemberPath]="'item.name'" [checkedMemberPath]="'checked'" [itemsSource]="data"></wj-multi-select> </div> <div class="col-xs-7"> <p> <b>Checked Items:</b> </p> <p *ngIf="theMultiSelect.checkedItems.length > 0"> {{ getCheckedItems(theMultiSelect) }} </p> </div> </div> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { return [ { "specific_type": "3067VIP10G-3G", "name": "My Crazy VIP", "generic_type": "vip10g", "id": 2, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": <any>null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.12", "port": 9700 } } }, { "specific_type": "EXE", "name": "My Crazy EXE", "generic_type": "exe", "id": 3, "model": "EXE", "properties": { "nports": 1152, "addr2": { "ip": <any>null, "port": 9671 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 9671 } } }, { "specific_type": "3067VIP10G-3G", "name": "Another VIP", "generic_type": "vip10g", "id": 4, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": <any>null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.1", "port": 9700 } } }, { "specific_type": "570IPG-3G18-SFPP12", "name": "My Crazy IPG", "generic_type": "ipg", "id": 1, "model": "570IPG-3G18-SFPP12", "properties": { "in_band_control": { "ibctrl1": { "tally_port": 6578, "sfp": 1, "src_ip": <any>null, "netmask": "255.255.255.0", "tally_ip": <any>null, "dest_ip": <any>null, "dest_port": 6577 }, "enabled": false, "ibctrl2": { "tally_port": 6578, "sfp": 3, "src_ip": <any>null, "netmask": "255.255.255.0", "tally_ip": <any>null, "dest_ip": <any>null, "dest_port": 6577 } }, "port_properties": { "sdi8": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi9": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi6": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi7": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi4": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi5": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi2": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi3": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi1": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi14": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi15": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi16": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi17": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi10": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi11": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi12": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi13": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi18": { "rx_sfp": "Dynamic", "direction": "In" } }, "addr2": { "ip": <any>null, "port": 161 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 161 } } } ]; } } body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <div class="row"> <div class="col-xs-5"> <wj-multi-select :placeholder="'Devices'" :displayMemberPath="'item.name'" :checkedItemsChanged='onCheckedItemsChanged' :checkedMemberPath="'checked'" :itemsSource="data"></wj-multi-select> </div> <div class="col-xs-7"> <p> <b>Checked Items:</b> </p> <p v-if="checkedItems.length > 0"> {{ getCheckedItems(checkedItems) }} </p> </div> </div> </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'; import { getData } from './data'; let App = Vue.extend({ name: 'app', data: function(){ return { data: getData().map(item => ({ item: item, checked: false })), checkedItems: [] } }, methods: { onCheckedItemsChanged: function(s){ this.checkedItems = s.checkedItems; }, getCheckedItems: function(ctrl) { let items = ctrl.map(checkableItem => checkableItem.item); return JSON.stringify(items); } } }) 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 MultiSelect - no $checked property</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> // list of country GDP and populations // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { return [ { "specific_type": "3067VIP10G-3G", "name": "My Crazy VIP", "generic_type": "vip10g", "id": 2, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.12", "port": 9700 } } }, { "specific_type": "EXE", "name": "My Crazy EXE", "generic_type": "exe", "id": 3, "model": "EXE", "properties": { "nports": 1152, "addr2": { "ip": null, "port": 9671 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 9671 } } }, { "specific_type": "3067VIP10G-3G", "name": "Another VIP", "generic_type": "vip10g", "id": 4, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.1", "port": 9700 } } }, { "specific_type": "570IPG-3G18-SFPP12", "name": "My Crazy IPG", "generic_type": "ipg", "id": 1, "model": "570IPG-3G18-SFPP12", "properties": { "in_band_control": { "ibctrl1": { "tally_port": 6578, "sfp": 1, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 }, "enabled": false, "ibctrl2": { "tally_port": 6578, "sfp": 3, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 } }, "port_properties": { "sdi8": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi9": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi6": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi7": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi4": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi5": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi2": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi3": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi1": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi14": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi15": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi16": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi17": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi10": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi11": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi12": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi13": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi18": { "rx_sfp": "Dynamic", "direction": "In" } }, "addr2": { "ip": null, "port": 161 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 161 } } } ]; } 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'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this.onCheckedItemsChanged = (sender) => { this.setState({ checkedItems: sender.checkedItems }); }; this.getCheckedItems = (ctrl) => { let items = ctrl.map((checkableItem) => checkableItem.item); return JSON.stringify(items); }; this.state = { data: getData().map((item) => ({ item: item, checked: false })), checkedItems: [] }; } render() { return <div className="container-fluid"> <div className="row"> <div className="col-xs-5"> <wjInput.MultiSelect placeholder="Devices" checkedMemberPath="checked" displayMemberPath="item.name" itemsSource={this.state.data} checkedItemsChanged={this.onCheckedItemsChanged}> </wjInput.MultiSelect> </div> <div className="col-xs-7"> <p> <b>Checked Items:</b> </p> {this.state.checkedItems.length > 0 ? (<p> {this.getCheckedItems(this.state.checkedItems)} </p>) : null} </div> </div> </div>; } } 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; } export function getData() { return [ { "specific_type": "3067VIP10G-3G", "name": "My Crazy VIP", "generic_type": "vip10g", "id": 2, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.12", "port": 9700 } } }, { "specific_type": "EXE", "name": "My Crazy EXE", "generic_type": "exe", "id": 3, "model": "EXE", "properties": { "nports": 1152, "addr2": { "ip": null, "port": 9671 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 9671 } } }, { "specific_type": "3067VIP10G-3G", "name": "Another VIP", "generic_type": "vip10g", "id": 4, "model": "3067VIP10G-3G", "properties": { "ndisplays": 1, "addr2": { "ip": null, "port": 9700 }, "snmp_monitor_port": 161, "nvidinputs": 36, "addr1": { "ip": "127.0.0.1", "port": 9700 } } }, { "specific_type": "570IPG-3G18-SFPP12", "name": "My Crazy IPG", "generic_type": "ipg", "id": 1, "model": "570IPG-3G18-SFPP12", "properties": { "in_band_control": { "ibctrl1": { "tally_port": 6578, "sfp": 1, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 }, "enabled": false, "ibctrl2": { "tally_port": 6578, "sfp": 3, "src_ip": null, "netmask": "255.255.255.0", "tally_ip": null, "dest_ip": null, "dest_port": 6577 } }, "port_properties": { "sdi8": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi9": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi6": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi7": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi4": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi5": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi2": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi3": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi1": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi14": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi15": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi16": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi17": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi10": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi11": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi12": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi13": { "rx_sfp": "Dynamic", "direction": "In" }, "sdi18": { "rx_sfp": "Dynamic", "direction": "In" } }, "addr2": { "ip": null, "port": 161 }, "snmp_monitor_port": 161, "addr1": { "ip": "127.0.0.1", "port": 161 } } } ]; }