【问题标题】:How to Reset a Arraycollection and Reinitialize and Overwrite the Arraycollection and refresh datagrid in FLEX 4如何在 FLEX 4 中重置 Arraycollection 并重新初始化和覆盖 Arraycollection 和刷新数据网格
【发布时间】:2013-09-27 15:31:13
【问题描述】:

我正在使用 flex 在数据网格中列出一个 Arraycollection,在数据网格内我有一个删除行的按钮,之后我通过从 java 服务获取数组再次重新分配相同的 Arraycollection

我的代码:

<mx:DataGrid width="100%" height="100%" dataProvider="{xxx}" >
<mx:columns>
    <mx:DataGridColumn dataField="name" headerText="Name"/>
    <mx:DataGridColumn dataField="status" headerText="Status"/>
    <mx:DataGridColumn dataField="path" headerTeUxt="Actions" wordWrap="true" minWidth="120">
        <mx:itemRenderer>
            <mx:Component>
            <mx:Script>
                <![CDATA[
                    protected function deliteminlist(event:MouseEvent):void
                    {
                            //delete a value in arrayCollection
                            //Fetch the array collection from java Service
                            //assigning to variable dataprovider variable
                            _view.xxx = null;
                            _view.xxx = temp;
                            //xxx is the arraycollection and dataprovider for the datagrid
                    }
                ]]>
            </mx:Script>
            <mx:Image source="@Embed(source='/assets/images/clone.png')" click="deliteminlist(event)" />
            </mx:Component>
        </mx:itemRenderer>
    </mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>

这是引发错误(发生内部错误 - 错误 #1010。 ) 并且数据不会在数据网格中刷新。

【问题讨论】:

  • 您看到了什么错误?从你的服务?还是来自 Flex?还是来自别的什么?
  • 看起来有竞争条件,最好调度事件/其他外部服务来处理服务调用,而不是项目渲染器。我不会在 deliteminlist 方法中执行任何业务逻辑,甚至不会从 arraycollection 中删除项目。
  • @Reboog711 实际上这是用于 vSphere Web 客户端插件,仅在 FLEX 层出现错误...我尝试单独调用 java 函数,它工作正常
  • @Vignesh 那么,错误是什么?请分享完整的堆栈跟踪。您的代码的哪一行导致了错误?作为参考点;您永远不应该尝试从 DataGrid 中删除一行。始终修改 dataProvider,DataGrid 将自动检测这些更改。如果您确实需要删除一行;通过改变 DataGrid 的高度来做到这一点;这将导致 DataGrid 显示更少的行。要根据渲染器按钮单击从 dataProvider 中删除项目,我总是调度冒泡事件并在包含 DataGrid 的组件中处理它;不是渲染器
  • 我没有从datagrid中删除一行我只从#datagrid.dataprovider中删除了一个项目......它在这个地方抛出错误_view.xxx = temp;如果我尝试更改 #datagrid.dataprovider = temp 那时间它的工作但不能覆盖变量

标签: apache-flex datagrid flex4


【解决方案1】:

您正在使用内联项渲染器。它的作用域与父视图不同,因此不能引用_view.xxx(不在作用域内)。

你可以试试outerDocument关键字来解决这个问题。

outerDocument.xxx = null;
outerDocument.xxx = temp;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-26
    • 1970-01-01
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多