14 Jul 2011 5:48 AM #1
getDragData - getTarget parameters
I am building a drag/drop for a grid panel using DragZone. The issue I am having is that when I drag the scroll bar I drag the whole grid instead of scrolling.
I've made a work-around where I'm checking for the class name of the dragged item in getDragData, which I don't believe is the correct method for doing so.
One this that is confusing, and I have searched for quite a while for an example or documentation, is the numeric value in this statement. What is the "10" for and is that the cause of this problem?
var sourceEl = e.getTarget(v.itemSelector,10);
18 Jul 2011 2:45 AM #2
The documentation for getTarget() can be found here:
It doesn't explain the details so I'll have a quick go.
When adding event listeners to the DOM it is quite inefficient to add them to all HTML elements in a component. Instead you can just add a single listener to one of the elements higher up, and the event will propagate up to that element. But in a structure like a grid or a tree, you still need to establish exactly which item (a row or a tree node) was clicked on.
Calling getTarget() will tell you which HTML element was clicked on but that isn't always what you want. Usually there is some sort of wrapper element for each item (be it a tree node or a grid row or whatever) and it is this wrapper element that you need to identify which item was clicked. The first argument passed to getTarget() is a CSS selector that will be used to walk up the DOM from the clicked element until it finds an element that matches the selector.
The second argument to getTarget() is a depth. It specifies how many elements should be tested against the CSS selector before giving up. I believe this is done purely for performance reasons. The default is 10.
23 May 2013 8:50 AM #3
Have you solved your issue with the scrollbars? I have a similar issue.
thanks in advance