skhye05 / nativescript-multi-select

Apache License 2.0
11 stars 6 forks source link

javascript implementation #7

Closed throwingdarts closed 5 years ago

throwingdarts commented 5 years ago

Is there a javascript (non-typescript) implementation?

throwingdarts commented 5 years ago

Here is the solution:

const MultiSelect = require("nativescript-multi-select").MultiSelect;
const AShowType = require("nativescript-multi-select").AShowType;

var MSelect = new MultiSelect();

MSelect.show({
  title: "Please Select",
  selectedItems: this._selectedItems,
  items: [
    { name: "A", value: "moi-a" },
    { name: "B", value: "moi-b" },
    { name: "C", value: "moi-c" },
    { name: "D", value: "moi-d" },
  ],
  bindValue: 'value',
  displayLabel: 'name',
  onConfirm: selectedItems => {
    selectedItems = ["moi-a", "moi-b"];
    console.log("SELECTED ITEMS => ", selectedItems);
  },
  onItemSelected: selectedItem => {
  console.log("SELECTED ITEM => ", selectedItem);
  },
  onCancel: () => {
    console.log('CANCEL');
  },
  android: {
    titleSize: 25,
    cancelButtonTextColor: "#252323",
    confirmButtonTextColor: "#70798C",
  },
  ios: {
    cancelButtonBgColor: "#252323",
    confirmButtonBgColor: "#70798C",
    cancelButtonTextColor: "#ffffff",
    confirmButtonTextColor: "#ffffff",
    showType: AShowType.TypeBounceIn
  }
});