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

查看:140
本文介绍了带有行号列的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天全站免登陆