Hrr, this thing is driving me nuts. I found out why it is not working 
in my Application. It is because I sort by column as soon as the Data
is loaded. If you sort by a column in your example it doesn't work
anymore either. 

How can I fix this?

Greets, Max

--- In [email protected], Max Frigge <[EMAIL PROTECTED]> wrote:
>
> Strange.. works for me too. Must have messed something up before.
Sorry for that. 
> Only little thing that is not 100% satisfying me is that when u
click delete extremely quick, it doesn't work fine anymore. But I
guess I have to live with that. 
> 
> Thanks for your effort mate!
> 
> Max
> 
> ----- Original Message ----
> From: Muzak <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Sunday, December 23, 2007 4:18:07 PM
> Subject: Re: [flexcoders] Re: Select next DataGrid item after one
removed
> 
> 
> 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" <tspratt@> 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" <m.frigge@>
> > 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
> 
> 
> 
> 
> 
> 
> 
> 
> 
>      
____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
>


Reply via email to