R – Prevent displaying of some data in last row of Flex Datagrid

actionscript-3apache-flexdatagriditemrenderermxml

I have some DataGrid with editable rows, which has also an option to add new row 'dynamically'. I mean, last row has some default data (e.g. "CLICK HERE TO ADD NEW ROW") and when user clicks on it, he can edit that value and new row will be eventually inserted.

However, I also have a column in same DataGrid which doesn't come from DataGrid's DataProvider. That column is used to delete specific row and it should only display clickable image with associated mouse click action (within custom itemRenderer).

I would like to display that image on every row except that last one.

Here is my DataGridColumn code so far:

<mx:DataGridColumn width="20" editable="false">
    <mx:itemRenderer>
        <mx:Component>
            <mx:VBox creationComplete="cc()">
                <mx:Script>
                    <![CDATA[
                        import mx.controls.Alert;
                        import mx.events.CloseEvent;

                        public function cc():void{
                            delImg.source = "assets/images/delete-icon.png";
                        }
                    ]]>
                </mx:Script>
                <mx:Image id="delImg" smoothBitmapContent="true" width="15" height="15" click="outerDocument.confirmDelete(event)"/>
            </mx:VBox>
        </mx:Component>
    </mx:itemRenderer>
</mx:DataGridColumn>

I suppose I should put some condition in my cc function and somehow compare current row's index or something with my dataProvider's length… I'm not really sure how to do that since I cannot get rowIndex property because I'm not working with DataGridEvent here…

Please help me with this one and thank you very much for any help! 🙂

Best Answer

A VBox does not implement IDropInListItemRenderer. A IDropInListItemRenderer gives you the "listData" property (which is of type "DataGridListData"). Furthermore, "listData.owner" will be the DataGrid object, and "listData.rowIndex" gives you the rowIndex property.

Related Topic