拖放图标问题 [英] Drag and Drop icon question

查看:104
本文介绍了拖放图标问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拖着项目从DataGrid和拖动我可以看到所选记录所有列,被越来越拖动。不过,我只是想显示一列(也许名称或记录的ID)?有没有一种方法来实现这一目标?另外,我可以显示一个图标,而不是记录或图像拖动。

I am dragging item from a datagrid and while dragging I could see all of the columns in the selected record, being getting dragged. However I only want to show one column (maybe name or id of the record)? Is there a way to achieve this? Also, could I show an icon or image instead of the record while dragging.

谢谢你们。

推荐答案

这可以通过扩展DataGrid中揭露 DataGridDragProxy 属性来完成。请查看 http://dgrigg.com/blog/2006/11/ 03 / DataGrid中拖动图像/ 工作示例

This can be done by extending the DataGrid to expose the DataGridDragProxy property. Check out http://dgrigg.com/blog/2006/11/03/datagrid-drag-image/ for a working example.

扩展的DataGrid:

<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
        import mx.controls.dataGridClasses.DataGridDragProxy;
        import mx.core.IUIComponent;

        /**
        * @public
        * class to use as DragProxy image
        * set the default value to the standard DataGridDragProxy class
        */
        [Bindable]
        public var dragProxyImage: Class = DataGridDragProxy; 

        override protected function get dragImage():IUIComponent
        {
            var image:IUIComponent = new dragProxyImage();
            image.owner = this;
            return image;
        }
        ]]>
    </mx:Script>
</mx:DataGrid>

使用DataGrid:

<controls:DataGrid 
    dataProvider="{dataSource}" 
    rowHeight="40" 
    dragEnabled="true" 
    height="140" 
    dragProxyImage="com.dgrigg.controls.CustomDragProxy" 
    allowMultipleSelection="true">

    <controls:columns>
        <mx:DataGridColumn headerText="Image" dataField="image">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Image source="{data.image}"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="Product" dataField="name"/>
        <mx:DataGridColumn headerText="Description" dataField="description"/>
    </controls:columns>
</controls:DataGrid>

这篇关于拖放图标问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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