String[] months = new String[]{
"Januar", "Februar", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
};
ITSASelectlist selectlist = Y.newITSASelectlist(ITSASelectlistConfig.create().items(months));
selectlist.on(ITSASelectlist.EVENT_SELECTCHANGE, new EventCallback<ITSASelectlistEvent>() {
@Override
public void call(ITSASelectlistEvent e) {
console.log("selected item index "+e.index()+" - value: "+e.value());
}
});
selectlist.render(parent);
//now another select list using custom items
// String[] colors = new String[]{
// "#FF0000", "#ff6600", "#ff77ee", "#66ff66", "#00ff66", "#66000ff"
// };
JsArray<ITSASelectlistItem> items = JsArray.createArray().cast();
for (int i = 0; i < 20; i++) {
String color = "#"+testUtil.randomColor().getHex();//colors[i];
ITSASelectlistItem item = ITSASelectlistItem.create()
.text("<div style='background-color:"+color+";'></div>")
.returnValue(color);
items.push(item);
}
ITSASelectlist selList2 = Y.newITSASelectlist(ITSASelectlistConfig.create()
.items(items)
.className("mycolors")
.listWidth(256)
.btnSize(2)
.iconClassName("itsa-icon-textcolor")
.defaultButtonText("")
);
selList2.on(ITSASelectlist.EVENT_SELECTCHANGE, new EventCallback<ITSASelectlistEvent>() {
@Override
public void call(ITSASelectlistEvent e) {
console.log("selected color: "+e.value());
}
});
selList2.render(parent.appendChild("<div id=\"divcolorpicker\"></div>"));
StyleSheet sty = Y.newStyleSheet();
//the main color label
sty.set("#divcolorpicker .itsa-selectlist-selectedmain div",