【问题标题】:Adding Removing Columns to Datagrid in Flex with States在带有状态的 Flex 中向 Datagrid 添加删除列
【发布时间】:2013-09-17 18:32:45
【问题描述】:

我正在开发一个应用程序,在第一个状态下,您使用 dataFields 选择日期范围,然后按一个按钮转到另一个状态并生成一个显示员工列表的数据网格和另一个可滚动的数据网格,其列动态生成并运行每个日期每个员工的小时数。

得到错误信息的步骤顺序是:

  1. 您选择一个日期范围,例如:从 01/01/2013 到 01/31/2013
  2. 您按下生成按钮(应用更改 currentState = "EmployeeList",一切正常)
  3. 按下返回按钮(返回初始状态,一切正常)
  4. 如果您更改的日期范围比之前的日期范围多,那么一切正常
  5. 如果您更改日期范围的天数少于日期范围之前的天数,则会出现下一个错误

    TypeError:错误 #1009:无法访问空对象引用的属性或方法。 在 mx.controls.dataGridClasses::DataGridBase/http://www.adobe.com/2006/flex/mx/internal::columnHeaderWordWrap() 在 mx.controls.dataGridClasses::DataGridItemRenderer/validateProperties() 在 mx.managers::LayoutManager/validateClient() 在 mx.controls.dataGridClasses::DataGridHeader/updateDisplayList() 在 mx.core::UIComponent/validateDisplayList() 在 mx.managers::LayoutManager/validateDisplayList() 在 mx.managers::LayoutManager/doPhasedInstantiation() 在 mx.managers::LayoutManager/doPhasedInstantiationCallback()

如果你用谷歌搜索,那么访问 apache 错误报告网站会得到一些结果

https://issues.apache.org/jira/browse/FLEX-22108

没有更多的......

但我找到了解决方法!

【问题讨论】:

    标签: apache-flex datagrid datagridcolumn


    【解决方案1】:

    首先要解决这个问题,我在谷歌上搜索了很多,我似乎没有人得到这个错误,我发现这是一个向 Apache 报告的 Flex Bug。我正在分析 DataGrid.as 和 DataGridColumn.as 中的原始代码以考虑可能的解决方案,我正在做一些测试,但没有任何效果。

    我做了什么,我希望它对某人有用

    当您单击后退按钮时,在 backbutton_clickEventLister() 内部和 currentState=""; 之前 我只是将 columns 数组设置为 new Array();

    protected function bttnBack_clickEventHandler(event:Event) : void {
        // This code line solved it
        dtGrdWorkedHours.columns = new Array();
        // Make sure of code it before state change stament
        currentState = "";
    }
    

    【讨论】:

    • 啊,是的,这个小混蛋。如果您要重置数据,请确保将 dataProvider 设置为 new ArrayCollection()(或任何空的 IList)而不是 null,否则会出现类似的恶作剧。
    猜你喜欢
    • 1970-01-01
    • 2011-06-12
    • 2013-01-11
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多