The following works for me:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute">
 
 <mx:Script>
  <![CDATA[
  
   private function deleteClickHandler(evt:Event):void {
    trace("Application ::: deleteClickHandler");
    var index:int = dg.selectedIndex;
    ac.disableAutoUpdate();
    ac.removeItemAt(index);
    dg.selectedIndex = index;
    ac.enableAutoUpdate();
   }
   
  ]]>
 </mx:Script>
 
 <mx:ArrayCollection id="ac">
  <mx:Object firstname="Jimi" lastname="Hendrix" />
  <mx:Object firstname="Frank" lastname="Zappa" />
  <mx:Object firstname="Miles" lastname="Davis" />
  <mx:Object firstname="Harry" lastname="Connick Jr." />
  <mx:Object firstname="John" lastname="Coltrane" />
  <mx:Object firstname="Dizzy" lastname="Gillespie" />
  <mx:Object firstname="Charlie" lastname="Parker" />
 </mx:ArrayCollection>
 
 <mx:VBox>
  <mx:DataGrid id="dg" dataProvider="{ac}" />
  <mx:Button id="delete_btn" label="delete" click="deleteClickHandler(event)" />
 </mx:VBox>
 
</mx:Application>

----- Original Message ----- 
From: "m.frigge" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, December 23, 2007 5:13 AM
Subject: [flexcoders] Re: Select next DataGrid item after one removed


Mh my Dataprovider is an ArrayCollctionboth, but methods do not work.
I still have the same effect.

--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> You might also try using callLater to set the index, to give the DG time
> to re-render.
> 
> Tracy
> 
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Muzak
> Sent: Saturday, December 22, 2007 11:13 AM
> To: [email protected]
> Subject: Re: [flexcoders] Select next DataGrid item after one removed
> 
> Disable the dataprovider from dispatching events before manipulating it
> and enable it again afterwards.
> Assuming you're using an ArrayCollection as dataProvider, the following
> works:
> 
> var index:int = dg.selectedIndex;
> ac.disableAutoUpdate();
> ac.removeItemAt(index);
> dg.selectedIndex = index;
> ac.enableAutoUpdate();
> 
> regards,
> Muzak
> 
> ----- Original Message ----- 
> From: "m.frigge" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Saturday, December 22, 2007 4:40 PM
> Subject: [flexcoders] Select next DataGrid item after one removed
> 
> 
> Hey there,
> 
> I hava a DataGrid and when I click a Delete Button, the selected item
> gets removed (obviously). But then I want the next item to be selected,
> so that you can keep on  pressing Delete and remove one item after the
> other.. as it is in Yahoo mail.
> 
> So I tried something like this:
> 
> oldIndex = grid.selectedIndex;
> removeItem(grid.selectedIndex) // functioin that removes item from
> arrayCollection
> grid.selectedIndex = oldIndex;
> 
> => but then it always selects one after the one I want to be selected.
> 
> So I tried something like this:
> 
> oldIndex = grid.selectedIndex;
> removeItem(grid.selectedIndex) // functioin that removes item from
> arrayCollection
> grid.selectedIndex = oldIndex -1;
> 
> => but then it always selects one before the one I want to be selected.
> 
> Strange.. isnt it?
> 
> Any ideas why this is happening..
> 
> Cheers, Max
> 
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
>





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to