带有行号列的 Flex DataGrid [英] Flex DataGrid with row number column

查看:23
本文介绍了带有行号列的 Flex DataGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想扩展 DataGrid 组件,以便为行号提供一个(只读)列,就像您在电子表格中看到的那样.我看到这篇文章 http://www.cflex.net/showFileDetails.cfm?ObjectID=735 但这取决于每一行的数据是唯一的,以便它可以索引到数组中.如果数据不是唯一的(例如空网格),则它不起作用.我该如何实施?

I want to extend the DataGrid component so that there is a (read-only) column for the row number like you see in spreadsheets. I came across this article http://www.cflex.net/showFileDetails.cfm?ObjectID=735 but it depends on the data being unique for each row so that it can index into the array. If the data is not unique (like for an empty grid) it doesn't work. How can I implement that?

推荐答案

我能够通过实现自定义 itemRenderer RowNumberRenderer.as 来做到这一点

I was able to do this by implementing a custom itemRenderer, RowNumberRenderer.as

package com.domain
{
    import mx.collections.IList;
    import mx.controls.Label;
    import mx.controls.listClasses.ListBase;

    public class RowNumberRenderer extends Label
    {
        public function RowNumberRenderer()
        {
            super();
        }

        override public function set data(value:Object):void
        {
            super.data = value;
            this.text = String(IList(ListBase(listData.owner).dataProvider).getItemIndex(data) + 1);                     
        }

    }
}

这篇关于带有行号列的 Flex DataGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆