Hi all i have modifed my code.
*
private* *function* moveRow():*void* {
*if*(dg.selectedIndex == -1) {
Alert.show(*"select the row you want"*);
*return*;
}
*if*(dg.selectedIndex ==0) {
*return*;
}
*var* selectRowIndex:Number = dg.selectedIndex;
*var* itemToshift:Object = dgDataprovider.getItemAt(selectRowIndex)*as*Object;
dgDataprovider.addItemAt(itemToshift,dg.selectedIndex-1);
dgDataprovider.removeItemAt(dg.selectedIndex);
dg.invalidateDisplayList();
}
*private* *function* moveRowDown():*void* {
*if*(dg.selectedIndex == -1) {
Alert.show(*"select the row you want"*);
*return*;
}
*if*(dg.selectedIndex == 0) {
*return
*
}
*var* selectRowIndex:Number = dg.selectedIndex;
*var* itemToShift:Object =
dgDataprovider.getItemIndex(selectRowIndex)*as*Object;
dgDataprovider.addItemAt(itemToShift,dg.selectedIndex+1);
dgDataprovider.removeItemAt(dg.selectedIndex);
dg.invalidateDisplayList();
}
<mx:HBox x="99" y="104" width="701" height="658" >
<mx:DataGrid id="dg" width="506" height="526" dataProvider="{dgDataprovider}"
editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Age" dataField="age"/>
</mx:columns>
</mx:DataGrid>
<mx:VBox height="100%" width="187" visible="true">
<mx:Button label="Move Up" click="moveRow()" id="up"/>
<mx:Button label="Button" click="moveRowDown()"/>
</mx:VBox>
</mx:HBox>
</mx:Application>
for up its working fine.
however when i am trying to move row down.
Its moving selected record down. but inserts -1 at above row.
can some body please help
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.