views:

1442

answers:

1

I have an an array of objects. I populate the datagrid from the array. The nmber of columns in the datagrid is fix i.e.5 and the first column always shows serial number (0,1,2,3,4). I have a link button called 'CLEAR' in the last column of the datagrid.

1> How do I make the clear button visible only when the row is particularly clicked ?

2> When the clear button is clicked, how do I make the contents of that particular row cleared. Not deleted, only cleared to insert data again. Also, the serial number (0,1,2,3,4) should not be cleared, nor deleted. How to do this ?

A: 

To make your clear button visible something like this would work. may have to play around with it a bit. private function onDatagridClick(event:ListEvent):void {

    if ( event.rowIndex == -1 ) {
        return;
    } 

    clearBTN[event.RowIndex].visible = true;
}

If you don't want to delete your column you need to place some data in there as the datagrid is bound by the data provider you can always add dummy data i.e. blank string, "Enter data" or a custom item renderer for when data is required.

AndrewB
Hey....i tried that..it says... undefined access to property RowIndex....also..how should the call to .is clearBTN be made...is it 'click' or 'change'....The idea of using a blank string is not correct..what happens is unless the cell is actually clicked..the data is not made blank..but i want the data to be cleared as soon as I click clear button...The dataprovider does not know that data is being cleared....
oops make that event datagridEvent and you should be all set.
AndrewB
invalidateList() function can also be used to reload the datagrid.