2012-03-16 2 views
0

이 기본 보이지만,이를 구현하는 방법을 찾을 수 없습니다 : 나는 많은 ListItems를 통해 반복해야하는Qooxdoo의 배열에서 SelectBox의 항목을 초기화하는 방법이 있습니까?

var array = ["item1","item2"...] 

대신 배열에서 선택 박스를 초기화하고 싶은

var selectBox = new qx.ui.form.SelectBox(); 
var test = ["item1", "item2"]; 
for (var i = 0; i < test.length; i++){ 
    var tempItem = new qx.ui.form.ListItem(test[i]); 
    selectBox.add(tempItem); 
} 

Qooxdoo에서 그렇게 할 수있는 방법이 있습니까?

답변

3

우선 루프의 더 우아한 버전 : 당신이 Qooxdoo (Link to documentation)에 문서를 데이터 바인딩을 살펴한다

var selectBox = new qx.ui.form.SelectBox(); 
test = ["item1", "item2"]; 

test.forEach(function(obj) { 
    selectBox.add(new qx.ui.form.ListItem(obj)); 
}, this); 

하지만. 컨트롤러와 함께 작업 할 때

var selectBox = new qx.ui.form.SelectBox(); 
test = ["item1", "item2"]; 

new qx.data.controller.List(new qx.data.Array(test), selectBox); 

당신이 쉽게 등 다른 위젯에 내가 찾던 정확히 무엇을

+0

감사를 변경 이벤트 바인딩처럼 좀 더 흥미로운 기능을 얻을이를 사용하는 경우이 같은 솔루션을 ! – Jonathan

관련 문제