【问题标题】:Prevent displaying of some data in last row of Flex Datagrid防止在 Flex Datagrid 的最后一行显示某些数据
【发布时间】:2011-01-01 21:25:42
【问题描述】:

我有一些带有可编辑行的 DataGrid,它还有一个“动态”添加新行的选项。我的意思是,最后一行有一些默认数据(例如“单击此处添加新行”),当用户单击它时,他可以编辑该值并最终插入新行。

但是,我在同一个 DataGrid 中也有一列不是来自 DataGrid 的 DataProvider。该列用于删除特定行,它应该只显示具有关联鼠标单击操作的可点击图像(在自定义 itemRenderer 中)。

我想在除最后一行之外的每一行都显示该图像。

到目前为止,这是我的 DataGridColumn 代码:

<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>

我想我应该在我的 cc 函数中设置一些条件,并以某种方式将当前行的索引或其他内容与我的 dataProvider 的长度进行比较...我不太确定该怎么做,因为我无法获得 rowIndex 属性,因为我' m 不能在这里使用 DataGridEvent...

请帮我解决这个问题,非常感谢您的帮助! :)

【问题讨论】:

    标签: apache-flex actionscript-3 datagrid mxml itemrenderer


    【解决方案1】:

    VBox 没有实现 IDropInListItemRenderer。 IDropInListItemRenderer 为您提供“listData”属性(属于“DataGridListData”类型)。此外,“listData.owner”将是 DataGrid 对象,“listData.rowIndex”为您提供 rowIndex 属性。

    【讨论】:

    • 在使用 itemRenderers 时要实现的另一个有用接口是 IDataRenderer,它为您提供“数据”属性; data 属性表示 currentRow 的对象。你可能想在你的 cc 函数中实现这样的东西: var grid1:DataGrid = DataGrid(DataGridListData(listData).owner); if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data)) return;
    • 非常感谢您提供这些有用且非常有用的信息 ;-)
    猜你喜欢
    • 1970-01-01
    • 2011-01-30
    • 2012-01-20
    • 2013-08-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 2010-10-05
    • 2011-06-05
    相关资源
    最近更新 更多