onyx.DataPicker

by EDWIN MAURICIO QUISHPE MALDONADO

JavaScript

enyo.kind({
    name: "onyx.DataPicker",
    kind: "enyo.DataRepeater",
    collection:null,
    //* @private
    observers: {
        updateSelectedMenuItem: ["selected"]
    },
    
    components: [
        {kind:"onyx.MenuItem", bindings:[
            {from:".model.name", to:".content",
             transform:function(v){console.log("value is ", v); return v;}}
        ]}
    ],
    containerOptions: {name: "container", kind:"onyx.Picker", classes: "enyo-data-repeater-container"},
    updateSelectedMenuItem: function() {
        var c$ = this.getClientControls();
        enyo.forEach(c$, function(c) {
            if(~enyo.indexOf(c.model, this._selection)) {
                c.set("active", true);
            }
        }, this);
        return true;
    }
});

enyo.kind({
    name: "ex.App",
    kind: "Control",
    published:{
        people:[],
        others:[]
    },
    bindings: [
        {from:".people", to:".$.picker1.collection"},
        {from:".others", to:".$.picker2.collection"}
    ],
    components: [
        {kind:"onyx.PickerDecorator", onChange:"changed", components:[
            {content:"Pick!"},
            {name:"picker1", kind:"onyx.DataPicker"}
        ]},
        {kind:"onyx.Button", content:"+ Person", ontap:"addPerson"},
        {kind:"onyx.Button", content:"Select Last Person", ontap:"selectLast"},
        {kind:"onyx.PickerDecorator", onChange:"changed", components:[
            {content:"Pick 2!"},
            {name:"picker2", kind:"onyx.DataPicker"}
        ]}
    ],
    create: enyo.inherit(function(sup) {
        return function() {
            sup.apply(this, arguments);
            this.set("people", new enyo.Collection([
                {name: "Alice", id:10},
                {name: "Bob", id:12},
                {name: "Clara", id:13}
            ]));
            
            console.log("data1", this.people.raw(), this.others);
            this.set("others", new enyo.Collection([
                {name: "England", id:1},
  ...