3.2.0

ui.list setSelectedItems problem

i think there is a problem with the setSelectedItems function.

the following code, should select first 3 items from "the second list" when user selects an option from "the first list". It does, but it also selects the first item from the first list. if i change [0,1,2] with [1,2,3] this time it selects the second item from the first list.

How to fix this?

<html>
<head><br/>
<link rel="STYLESHEET" type="text/css" href="styles/system/aw.css">
<script type="text/javascript" src="lib/aw.js"></script>
</head>
<body>
<script type="text/javascript">
var list1 = new AW.UI.List;
list1.setId("list1");
list1.setItemText(["a","b","c","d","e","f","g","h","i","j"]);
list1.setItemValue(["1","2","3","4","5","6","7","8","9","10"]);
list1.setItemCount(10);
list1.setSelectionMode("multi");
list1.onSelectedItemsChanged = function(array){
    alert('list1 changed');
    list2.setSelectedItems([0,1,2]);	
    }
document.write(list1);
</script><br/>
<br/>
<script type="text/javascript">
var list2 = new AW.UI.List;
list2.setId("list2");
list2.setItemText(["a","b","c","d","e","f","g","h","i","j"]);
list2.setItemValue(["1","2","3","4","5","6","7","8","9","10"]);
list2.setItemCount(10);
list2.setSelectionMode("multi");
list2.onSelectedItemsChanged = function(array){
    alert('list2 changed');
} 
document.write(list2);
</script>
</body>
</html>
September 19,
Yes, this is a bug. The selection controller uses a static array between 'before' and 'after' states to process the selection. The possible workaround is to launch second list update with setTimeout call -

list1.onSelectedItemsChanged = function(array){
    this.setTimeout(function(){
      list2.setSelectedItems([0,1,2]);    
    });
  }
Alex (ActiveWidgets)
September 23,

This topic is archived.

See also:


Back to support forum