如何在Flex 3上的列表控件上動態設置selectedIndices?如何在flex 3上的列表控件上動態設置selectedIndices?
我在重複控制中使用列表。我有一個選項多選列表。當我選擇多個選項時,我可以將選定的索引作爲數組存儲並存儲在數據庫中。同時列出所選索引屬性的列表控件中的選定值時,它將不會正確設置。在這裏我給了我的代碼。
<mx:VBox y="30" x="1" id="vboxState">
<mx:Repeater id="rptrRadioState" dataProvider="{rptrArr}">
<mx:HBox>
<mx:List id="cmbstateradio" selectedIndices="{new Array(1,3)}" dataProvider="{listarr}" allowMultipleSelection="true" change="(event.currentTarget.getRepeaterItem().selectedval = cmbstateradio[event.target.repeaterIndices].selectedIndices)"/>
</mx:HBox>
</mx:Repeater>
</mx:VBox>
它工作正常。但是,如果我會用下面提到的方式嘗試,那不是工作。
[Bindable]
public var arr:Array = new Array(1,3);
[Bindable]
public var rptrArr:ArrayCollection = new ArrayCollection([{label:"TestA",data:0,selectedval:new Array(1,3)},{label:"TestB",data:1,selectedval:arr},{label:"TestC",data:2,selectedval:arr}]);
<mx:VBox y="30" x="1" id="vboxState">
<mx:Repeater id="rptrRadioState" dataProvider="{rptrArr}">
<mx:HBox>
<mx:List id="cmbstateradio" selectedIndices="{new Array(rptrRadioState.currentItem.selectedval)}" dataProvider="{listarr}" allowMultipleSelection="true" change="(event.currentTarget.getRepeaterItem().selectedval = cmbstateradio[event.target.repeaterIndices].selectedIndices)"/>
</mx:HBox>
</mx:Repeater>
</mx:VBox>
我試了。它也沒有work.i不能得到解決方案... – venkat 2014-10-06 05:52:16
我更新了我的答案。 – Crabar 2014-10-06 07:08:30
謝謝crabar.But它也沒有工作。這樣只會選擇第一個索引。這是零指數。 – venkat 2014-10-06 10:21:10