Flex 中DataGrid可编辑的优先级关系

这两天在做一个FLEX的后台,用FLEX BUILDER3.0自动生成的数据表有点问题,所以改成自己做了。自己做的过程中发现,如果是让某一个dataField不可编辑。FLEX BUILDER3.0自动生成的代码是用

dataGrid.addEventListener(DataGridEvent.ITEM_EDIT_BEGINNING, editCellHandler);

private function editCellHandler(e:DataGridEvent):void
{
    if(e.dataField == "video_idCol") //video_idCol为不可编辑项名
    {
        e.preventDefault();
        return;
    }
}

我觉得有点烦琐,所以就自己做了一下几种尝试了:

1.不好用的方法

<mx:DataGrid id="videolist" width="100%" height="100%" >
    <mx:columns>
        <mx:DataGridColumn headerText="ID" dataField="video_id" editable="false"/>
        <mx:DataGridColumn headerText="视频类别" dataField="video_class"  editable="true"/>
        <mx:DataGridColumn headerText="视频名" dataField="video_name" editable="true"/>
        <mx:DataGridColumn headerText="视频地址" dataField="video_path" editable="true"/>
    </mx:columns>
</mx:DataGrid>

2.正确的做法

<mx:DataGrid id="videolist" width="100%" height="100%" editable="true“/>
    <mx:columns>
        <mx:DataGridColumn headerText="ID" dataField="video_id" editable="false"/>
        <mx:DataGridColumn headerText="视频类别" dataField="video_class" />
        <mx:DataGridColumn headerText="视频名" dataField="video_name" "/>
        <mx:DataGridColumn headerText="视频地址" dataField="video_path" />
    </mx:columns>
</mx:DataGrid>

 

看来还有有优先级别的。

Advertisements

One response to this post.

  1. 晕晕的~~~~ 

    回复

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: