简体   繁体   English

Flex拖放

[英]Flex Drag and Drop

I am creating an application that will allow users to model configuration information by allowing them to Drag and Drop objects from a Flex Tree into a DataGrid. 我正在创建一个应用程序,该应用程序允许用户通过将对象从Flex Tree拖放到DataGrid中来对配置信息进行建模。

I know that both the Tree and DataGrid both support Drag and Drop quite well. 我知道Tree和DataGrid都很好地支持拖放。

My problem is that I want users to drop items from the Tree into a particular Datagrid cell. 我的问题是我希望用户将树中的项目拖放到特定的Datagrid单元中。 I think standard drop events into the Datagrid try to fill the whole datagrid row by default. 我认为默认情况下,将标准放置事件放入Datagrid会尝试填充整个datagrid行。 This is not what I want, I want to drop components into a cell only. 这不是我想要的,我只想将组件放入单元格中。

I was thinking that each time an object is dropped onto the datagrid you would have to: - Get the cell location (x,y) the object was dropped into - Get all the existing cell objects and rebuild that datagrid row from scratch(dynamically) adding the new dropped object to the row in its correct position. 我在想,每次将对象放到数据网格上时,您都必须:-获取将对象放到的单元格位置(x,y)-获取所有现有的单元格对象,并从头开始(动态)重建该数据网格行将新放置的对象添加到该行的正确位置。 Thus giving the illusion that you can drop into a cell - its a bit of a fudge but I think it could work :) 因此,给人一种幻想,即您可以掉入一个单元中,这有点像是软糖,但我认为它可以起作用:)

Any feedback would be great. 任何反馈将是巨大的。 Thanks in advance Mike 预先感谢迈克

Turn drag and drop off for the datagrid. 拖放数据网格。

Write a custom renderer which listens to itself for the DragEnter / DragDrop events. 写监听到本身为dragenter /事件的DragDrop一个自定义的渲染器。 In the handler for the drop event, add the item(s) to the data (at the variable referenced by that column). 在处理程序中的放置事件,添加项目(S)的数据(在由该列中引用的变量)。

If your renderer is bound to the item, it will now update. 如果渲染器绑定到该项目,则现在将更新。

((Note that isn't best practice, you'd want to dispatch an event containing the renderer's data item, the variable it was representing and the item(s) dropped, and then manipulate the dataprovider outside of the renderer)) ((请注意,这不是最佳实践,您希望分派一个事件,该事件包含渲染器的数据项,它表示的变量和删除的项,然后在渲染器外部操作dataprovider))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM