使用States向Flex中的Datagrid添加删除列

时间:2013-09-17 18:32:46

标签: flex datagrid datagridcolumn

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

获取错误消息的步骤顺序为:

  1. 您可以选择日期范围,例如:从2013年1月1日到2013年1月31日
  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()

  6. 如果你谷歌它,那么一些结果需要访问apache bug报告网站

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

    没有了......

    但我找到了解决方法!

1 个答案:

答案 0 :(得分:1)

首先要解决这个问题我正在谷歌搜索很多,我看起来没有人得到这个错误,我发现这是一个向Apache报告的Flex Bug。我正在分析DataGrid.as和DataGridColumn.as中的原始代码,以考虑可能的解决方案,我正在进行一些测试而没有任何工作。

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

单击后退按钮时,在backbutton_clickEventLister()内和currentState =“”之前; 我只是将列数组设置为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 = "";
}