RadListView-无法将元素移出屏幕

时间:2018-08-16 09:37:03

标签: android nativescript radlistview

我的过滤器页面上有一个RadListView,其中带有复选框。当用户按下应用过滤器按钮时,我会遍历所有选项并检查是否已选中。问题是屏幕上的项目和用户未滚动以加载它们,请返回undefined

setTimeout(function(){
  for (var i = 0; i < context.designs.length; i++) { //context.designs is the array of all designs
    if(selectedDesigns.indexOf(context.designs[i].id) != -1){ //selectedDeigns is the list of designs user selected
        console.log("checkd: "+context.designs[i].name);
        var selCheckbox = page.getViewById("check"+context.designs[i].id);
        console.log(selCheckbox);
        if(selCheckbox != undefined)
            selCheckbox.toggle();
        else //if checkbox is undefined, I try scrolling to it and checking it after a timeout
            checkSelectedBoxes(i);
    }
  }
}

function checkSelectedBoxes(i){
    console.log(i);
    designList.scrollToIndex(i);
    setTimeout(function(){
        var selCheckbox = page.getViewById("check"+context.designs[i].id);
        console.log(selCheckbox);
        if(selCheckbox != undefined)
            selCheckbox.toggle();
    }, 100);
}

编辑:我添加了另一个超时,现在显示所有复选框,但是有更好的选择来加载屏幕项目而不滚动到它们。这种方法感觉...很y吗?

0 个答案:

没有答案