Flex AdvancedDataGrid 树自定义拖动
我想在 AdvancedDataGrid 树结构上实现自定义拖动,它只允许在树枝(而不是叶子)上拖动。
我在这方面遇到了很大的困难,尝试使用 MouseDown 事件,但运气不佳!
好吧,我想我已经可以通过鼠标按下来判断该项目是否是树叶的分支。 关于如何使用高级数据网格执行自定义拖动有任何帮助吗?
var grid : AdvancedDataGrid = AdvancedDataGrid(event.currentTarget); if(grid.selectedItem.hasOwnProperty("categories") && grid.selectedItem.categories!=null) { Alert.show("yes"); } else { Alert.show("no"); }
I'd like to implement a custom drag on an AdvancedDataGrid tree structure, which only allows the drag on the branches (not leaves).
I'm having much difficultly with this, trying to use the MouseDown event, but not having luck!
Okay, I think I've got the mousedown able to figure out if the item is a branch of leaf. Any help on how to perform the custom drag with an advanceddatagrid??
var grid : AdvancedDataGrid = AdvancedDataGrid(event.currentTarget); if(grid.selectedItem.hasOwnProperty("categories") && grid.selectedItem.categories!=null) { Alert.show("yes"); } else { Alert.show("no"); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试了很多不同的方法来做到这一点,这是我想出的最好的解决方案。 AdvancedDataGrid 已经内置了处理 mouseMove/mouseOver/mouseDown 事件的逻辑,因此无需重新创建它。 只需重写 DragEvent 处理程序即可。
我复制了在几个需要类似功能的应用程序中使用的代码,包括确定该项目是否可以拖动的逻辑,以及确定是否可以将其放置在某个位置的一些逻辑。 我还添加了广泛的评论来帮助解释为什么要做某些事情。 我希望这有帮助!
CustomADG.as:DragProxyContainer.as
:
I've tried many different ways to do this, and this is the best solution that I have come up with. AdvancedDataGrid already has logic built in to handle the mouseMove/mouseOver/mouseDown events, so there's no need to recreate it. Simply override the DragEvent handlers.
I have duplicated the code I use in several applications that need similar functionality, included your logic for determining if the item can be dragged, as well as some logic to determine if it can be dropped in a certain location. I have also included extensive commenting to help explain why certain things are done. I hope this helps!
CustomADG.as:
DragProxyContainer.as:
如果对象是叶子,您可以尝试处理
dragEnter()
事件来停止拖动。You can try handling the
dragEnter()
event to stop dragging if the object is a leaf.