巴鲁's profile岩屋PhotosBlogListsMore Tools Help

Blog


    September 18

    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>

     

    看来还有有优先级别的。

    Comments (1)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    JIAwrote:
    晕晕的~~~~ 
    Sept. 18

    Trackbacks

    The trackback URL for this entry is:
    http://snowyrock.spaces.live.com/blog/cns!B8CBEB7169880B1D!395.trak
    Weblogs that reference this entry
    • None