PDA

View Full Version : How do i deselect an item within a datagrid?


lowRider
05-08-2007, 02:28 AM
Hi There,

I'm not a professional actioniscriptor by any means, but am hoping that someone can help me with a simple (but frustrating) problem i'm having.

How do i deselect a row within a datagrid component. At runtime, the grid appears without any of the rows selected - as expected. Upon a mouse click, the "clicked-on" row is highlighted.

Is there a default value that can be set to selectedIndex...

e.g.jobInfo_grd.selectedIndex = -1 ?

cheers,
j.

ventodimare
08-08-2007, 12:08 PM
Hi,
if you have in a mxml file:
<mx:DataGrid id="basketGrid" ....>
<mx:columns>
...
</mx:columns>
</mx:DataGrid>

In your action script you can deselect a row eventually selected by doing:
basketGrid.selectedIndex=-1;

I've also tried, with success, this instruction:
basketGrid.selectedItem=-1;

Hope this helps,
regards.

rbz
04-15-2008, 05:19 AM
with a List component I had better luck using:
my_list.selectedIndex = null;

haven't tried with DataGrid, though...
...and sorry, just noticed this is a Flex thread (i'm on flash), donnow if the solution applies, maybe it does