That's a bug.  A simpler reproduction case is this:
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";> 
<mx:Script>
<![CDATA[
 private function workaround():void
 {
  var i:int = list.selectedIndex;
  list.selectedIndex = -1;
  list.selectedIndex = i;
 }
]]>
</mx:Script>
<mx:List id="list" dataProvider="['a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i']" allowMultipleSelection="true" >
</mx:List>
<mx:Button label="delete row 'c'"
click="list.dataProvider.removeItemAt(2)" />
<mx:Text text="Select 'd', hit button, try to shift select 'e'.  Should
select both 'd' and 'e'" />
<mx:Button label="workaround" click="workaround()" />
</mx:Application>

and the workaround is to set selectedIndex to -1.  Please use the
simpler test case when filing the bug.  Thanks.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of e_baggg
Sent: Thursday, September 27, 2007 4:34 PM
To: [email protected]
Subject: [flexcoders] Cannot multiple select rows after deleting row
from a List



I was able to recreate this issue in a very simple example included
below. If I select a row, delete it (which auto selects the next
row)...if I then Shift-click another row...the highlighted row is not
included in the selected group. Any future shift-clicks from this
point work as expected. has anyone encountered this? I included a
sample Flex 2 mxml app with steps. Thanks in advance for your help:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="vertical">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var dataAll : ArrayCollection = new
ArrayCollection(["aa","bb","cc","dd","ee","ff","gg","hh","ii",]);

private function deleteRow() : void
{
var selectedIndices : Array = dg.selectedIndices;
var highestIndex : int = getEmailWithHighestIndex(selectedIndices);
trace("highestIndex=" + highestIndex);
trace("pre delete=" + selectedIndices);
highestIndex++;
dg.selectedIndex = highestIndex;
trace("after set=" + dg.selectedIndex);
for each(var k:int in selectedIndices)
{
dataAll.removeItemAt(k);
}
dg.selectedIndex = dg.selectedIndex;
trace("post delete (indices)=" + dg.selectedIndices);
trace("post delete (index)=" + dg.selectedIndex);
}
private function mouseDownHandler() : void
{
trace('mouseDOWN (indices)=' + dg.selectedIndices);
trace('mouseDOWN (index)=' + dg.selectedIndex);
trace('----------');
}
private function getEmailWithHighestIndex(selectedIndices : Array) : int
{
var highestEmailIndex : int = 0;
for(var g:int=0 ; g < selectedIndices.length; g++)
{
var currEmailIndex : int = int(selectedIndices[g]);
if(currEmailIndex > highestEmailIndex)
{
highestEmailIndex = currEmailIndex;
} 
}
return highestEmailIndex;
} 
]]>
</mx:Script>
<mx:HBox width="100%" height="75%">
<mx:TextArea width="100%" height="100%" htmlText="1.) Select 'cc'
&lt;br&gt;2.) Hold down 'Shift' and select 'dd' (notice how both rows
are selected). 
&lt;br&gt;3.) Select 'cc' so it is the only row that is selected is
'cc'.&lt;br&gt;4.)Click delete ('dd' is now selected)&lt;br&gt;5.) Now
Shift-click 'ee'. This should select both rows but it does not. Why???
"/>
<mx:VBox width="100%">
<mx:List id="dg" dataProvider="{dataAll}" width="200" height="179"
allowMultipleSelection="true" mouseDown="{mouseDownHandler()}"/>
<mx:Button label="delete" click="{deleteRow()}"/>
</mx:VBox>
</mx:HBox>
</mx:Application>



 

Reply via email to