Question

all

i am working now days on WebOs 3.0 This question may not require WebOs knowledge.

My problem is i am using a list selector is like a HTML dropdown.

its static code

{kind: "ListSelector", name: "mySelector"}

this.$.mySelector.setItems( [ { caption: "test 1", value: 1 }, { caption: "test 2", value: 2 } ]);
this.$.mySelector.setValue(2);

Dynamic way to display

for (var j=0; j<this.cnt; j++)
      {
      //alert(this.data[j].channelName);
      this.$.mySelector.setItems( [ { caption: this.data[j].channelName, value: this.data[j].channelId }]);

      }

Because i am keep replacing all of your items with 'setItems'. it show me only last value of my db.

Was it helpful?

Solution

Why not change the loop to build up a temporary array and then call the setItems function?

var items = [];
for (var j=0; j<this.cnt; j++)
{
    items.push({caption: this.data[j].channelName, value: this.data[j].channelId});
}
this.$.mySelector.setItems( items );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top