开发者

Dynamic ListSelector Array problem

开发者 https://www.devze.com 2023-04-03 05:14 出处:网络
all 开发者_开发问答 i am working now days on WebOs 3.0 This question may not require WebOs knowledge.

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.


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 );
0

精彩评论

暂无评论...
验证码 换一张
取 消