【问题标题】:flex datagrid - item renderers and skipping rowsflex datagrid - 项目渲染器和跳过行
【发布时间】:2010-11-06 15:29:27
【问题描述】:

嗨,

我有一个包含 6 列的数据网格,每列都有自己的项目渲染器。在第一列中,我希望能够检查该列是否包含一些有效数据,如果没有,那么我想跳过这一行并转到下一行。换句话说,我想要一种方法来告诉我的数据网格停止处理当前数据对象的其余项目渲染器并跳到下一个。有任何想法吗?

【问题讨论】:

    标签: apache-flex datagrid


    【解决方案1】:

    我想说最好的办法是在 ListCollectionView 对象(例如 ArrayCollection)上使用 filterFunction 属性。这使您可以在它们显示在网格中之前过滤掉您不想在 DataGrid 中显示的对象,并且应该避免完全处理任何 itemRenderer。

    【讨论】:

      【解决方案2】:

      如果您仍然希望“跳过”对象显示在数据网格中,并且只是更改项目渲染器对其的响应方式,那么您需要在渲染器中为此编写代码。

      在项目渲染器内部,您可以访问前列的数据值。您应该检查项目渲染器中可用的 listData 属性,并使用您的发现来配置项目渲染器的显示方式。

      您可以在此处找到有关 listData 的信息:http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridListData.html

      要检查以前的值,您可以编写如下代码:

      var dgListData:DataGridListData = DataGridListData( listData );
      
      // Process all columns before the current one.
      for ( var i:int = 0; i < dgListData.columnIndex; i++)
      {
          // Do something here to examine previous data
      
          // If we should stop processing based on previous values
          // then hide everything inside of this renderer (perhaps
          // move to a state name 'empty' that has no children), else
          // move to the state that renders something.
          currentState = shouldSkipObject ? 'empty' : 'normal';
      }
      

      如果您在项目渲染器内编写代码时需要更具体的帮助,请提供数据网格内数据的样例以及项目渲染器实际应该做什么的描述。

      【讨论】:

        猜你喜欢
        • 2011-08-16
        • 1970-01-01
        • 2011-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多