Results 1 to 2 of 2
  1.    #1  
    Hi all,

    I'm hoping that someone can help me with a problem that's been driving me up a wall for two days now. I have a multidimensional array that holds values read out from a CSV file. I'm looking to pick two of the values from that array and have them be the label and value for the choices of the ListSelector. I've tried different variations of code with no luck.

    The code below will display the list selector, but only gives a blank list when clicked. I've verified that the data actually is in my test array (for example, test[0][0] resolves to 1).


    var stops = [];

    for (var z = 0; z < test.length; z++) {
    stops[z] = {
    label: test[z][1],
    value: test[z][0]
    };
    }

    this.controller.setupWidget("arrive",
    this.attributes = {
    label: $L("Arrive"),
    labelPlacement: Mojo.Widget.labelPlacementLeft,
    },
    this.model = {
    choices: [stops],
    value: 2,
    disabled: false
    }
    );

    Mojo.Event.listen(this.controller.get("arrive"), Mojo.Event.propertyChange, this.handleUpdate);
  2.    #2  
    ...aaaaaaaaand I finally figured it out. Hope the code is of help to someone.

    var stops = [];
    for (var z = 0; z < test.length; z++) {
    stops[z] = {
    label: test[z][1],
    value: test[z][0]
    };
    }

    this.departAttributes = {
    label: $L("Depart"),
    labelPlacement: Mojo.Widget.labelPlacementLeft,
    };

    this.departModel = {
    value: 1,
    choices: [ {label: 'Test', value: 0},
    {label: 'Two', value: 1},
    {label: 'Three', value: 2}
    ],
    disabled: false
    };

    this.controller.setupWidget("depart", this.departAttributes, this.departModel);
    this.departModel ["choices"] = stops;
    this.controller.modelChanged(this.departModel, this);

    Mojo.Event.listen(this.controller.get("depart"), Mojo.Event.propertyChange, this.handleDepart.bind(this));

Tags for this Thread

Posting Permissions