chr15athome
12-16-2008, 10:32 PM
Hi
I have a data grid that I want to select a row and then hit a button to delete the row. I have used the code below to achieve this but the only way I can get the selected row ID is if a field is editted first. Any clicks on uneditable cells prior to this do not pass on the rowID. Once a cell has been edited then all other cells respond to the click events.
import fl.events.ListEvent;
dataGrid.addEventListener(ListEvent.ITEM_CLICK, clickHandler, false, 100);
function clickHandler(e:ListEvent):void
{
//dataGrid.click
rowID = Number(e.rowIndex);
trace(Number(e.rowIndex));
}
delete_btn.addEventListener(MouseEvent.CLICK, removeBasketItem);
function removeBasketItem(event:MouseEvent){
dataGrid.removeItemAt(rowID);
shop_cart.removeElementAt(rowID);
trace("item removed at " + rowID);
}
I have a data grid that I want to select a row and then hit a button to delete the row. I have used the code below to achieve this but the only way I can get the selected row ID is if a field is editted first. Any clicks on uneditable cells prior to this do not pass on the rowID. Once a cell has been edited then all other cells respond to the click events.
import fl.events.ListEvent;
dataGrid.addEventListener(ListEvent.ITEM_CLICK, clickHandler, false, 100);
function clickHandler(e:ListEvent):void
{
//dataGrid.click
rowID = Number(e.rowIndex);
trace(Number(e.rowIndex));
}
delete_btn.addEventListener(MouseEvent.CLICK, removeBasketItem);
function removeBasketItem(event:MouseEvent){
dataGrid.removeItemAt(rowID);
shop_cart.removeElementAt(rowID);
trace("item removed at " + rowID);
}