How to fires event after Drag & Drop on TreePanel
On an ExtJS drag and drop tree using the drop or beforedrop listeners dont seem to fire
How do I make an ExtJS drag and drop tree be copy only -- not remove items from the display?
I'm trying to take the new parent of the moved node:
drop: function (node, data, overModel, dropPosition) {
var theNode = data.records[0];
console.log( theNode.data.parentId );
console.log( theNode.parentNode.id );
},
but :
note 1: the node parameter is not the real TreeNode, just a HTML tag.
note 2: The theNode.parentNode is not updated and I'm taking the old node parent (before the drag). It will be updated AFTER the drop function.
How can I take the new node parent?
Solved (ExtJS 6.2.x).
drop: function (node, data, overModel, dropPosition) {
var thisIsTheMovedNode = data.records[0];
var thisIsTheNewParentNodeData = overModel.data;
var thisIsTheOldParentNodeData = data.records[0].parentNode;
}
The new parent node ID is : overModel.data.id;
Related
When I try to load context menu in here map, it shows error in firebug as "ReferenceError: nokia is not defined"
What's it that I'm doing wrong.
Imported js files:
The code that creates the bug is:
createContextMenu(map);
function createContextMenu(map) {
contextMenu = new nokia.maps.map.component.ContextMenu();
/* Add Custom Context Menu Items */
//This adds three items with a menu separator
menuItems1 = function (contextMenuEvent, group) {
group.addEntry("Menu Item 1",
function (activationEvent) {alert("Menu Item 1 clicked"); });
group.addEntry("Menu Item 2",
function (activationEvent) {alert("Menu Item 2 clicked"); });
group.addEntry("Menu Item 3",
function (activationEvent) {alert("Menu Item 3 clicked"); });
};
contextMenu.addHandler(menuItems1);
map.components.add(contextMenu);
}
Currently working on jquery 1.9.1
and
Firefox 48
HERE Javascript API have moved to the namspace "H" with version 3.X onward hence "nokia." would not work any more. With respect to context menu functionality, it can achieved by adding an event listener on the map
Example: https://developer.here.com/documentation/examples/maps-js/events/context-menu
/**
* Adds context menus for the map and the created objects.
* Context menu items can be different depending on the target.
* That is why in this context menu on the map shows default items as well as
* the "Add circle", whereas context menu on the circle itself shows the "Remove circle".
*
* #param {H.Map} map Reference to initialized map object
*/
function addContextMenus(map) {
// First we need to subscribe to the "contextmenu" event on the map
map.addEventListener('contextmenu', function (e) {
// As we already handle contextmenu event callback on circle object,
// we don't do anything if target is different than the map.
if (e.target !== map) {
return;
}
// "contextmenu" event might be triggered not only by a pointer,
// but a keyboard button as well. That's why ContextMenuEvent
// doesn't have a "currentPointer" property.
// Instead it has "viewportX" and "viewportY" properties
// for the associates position.
// Get geo coordinates from the screen coordinates.
var coord = map.screenToGeo(e.viewportX, e.viewportY);
// In order to add menu items, you have to push them to the "items"
// property of the event object. That has to be done synchronously, otherwise
// the ui component will not contain them. However you can change the menu entry
// text asynchronously.
e.items.push(
// Create a menu item, that has only a label,
// which displays the current coordinates.
new H.util.ContextItem({
label: [
Math.abs(coord.lat.toFixed(4)) + ((coord.lat > 0) ? 'N' : 'S'),
Math.abs(coord.lng.toFixed(4)) + ((coord.lng > 0) ? 'E' : 'W')
].join(' ')
}),
// Create an item, that will change the map center when clicking on it.
new H.util.ContextItem({
label: 'Center map here',
callback: function() {
map.setCenter(coord, true);
}
}),
// It is possible to add a seperator between items in order to logically group them.
H.util.ContextItem.SEPARATOR,
// This menu item will add a new circle to the map
new H.util.ContextItem({
label: 'Add circle',
callback: addCircle.bind(map, coord)
})
);
});
}
I am playing with using a Kendo Sortable. I would like to drag an item from one list in order to populate another, but I need to leave that item in the original list. Does anyone have an idea on how to do this?
An alternative to sortable might be draggable & dropTarget.
Have a look at Moving items from one list to another.
$("#listB").kendoDropTarget({
dragenter: addStyling,
dragleave: resetStyling,
drop: function(e) { //apply changes to the data after an item is dropped
var draggableElement = e.draggable.currentTarget,
dataItem = listA_DS.getByUid(draggableElement.data("uid")); //find the corresponding dataItem by uid
//--- Change --- listA_DS.remove(dataItem); //remove the item from ListA
listB_DS.add(dataItem); //add the item to ListB
resetStyling.call(this); //reset visual dropTarget indication that was added on dragenter
}
});
Modified Example from that page
I have some draggables and a sortable container
when I drag that in to the sortable container I need to get the draggable instance,ie I need to find which draggable element I have dragged in to it.
Now the problem is, I have coded like, when I drag a draggable into the sortable area, it becomes the part of the sortable area.
There is no way to find out which draggable I have dragged in.
Can you guys please help.?
Thanks in advance.
This is kind of old, but I solved this by getting the event.target inside the drop function.
$('.my-drop-zone').droppable ({
drop: function(event, ui) {
// item that was dragged
var draggedItem = ui.draggable; //or ui.draggable.attr('id');
// item it was dropped on
var droppedOnItem = $(event.target); //or $(event.target).attr('id');
}
});
I have the following setup:
$('.my-list').sortable({
handle: '.drag-handle',
start: function(event, ui ) {
//check to see if allow drag and drop
var should_disable = check-code-goes-here ;
if (should_disable) {
//how to disable
}
},
stop: function(event, ui ) {
}
});
When dragging a .drag-handle element, I need to check a condition to see if it is allowed to be dragged and dropped. If yes, go as normal. If not, I would like to disable the whole drag/drop operation. Note that I cannot determine whether a .drag-handle element should be draggable or not at page load, which is why I need to check at the time of each drag/drop operation.
Thanks and regards.
Check this JSFiddle link
http://jsfiddle.net/shuklendu/uacc7/17/
in that example a class 'fixed' added to item which don't want to drag and cancel property set to sortable by
$("#sortable").sortable({
cancel: ".fixed"
});
I am having some dificulties with the following. I have an object that is resizable. The code looks as following:
var alsoresizablevar1;
var alsoresizablevar2;
object.resizable({
handles: {se: object.find(".resize")},
alsoResize: alsoresizablevar1, alsoresizablevar2
});
How can i add the 2 variables to the alsoResize option so they are resized together wit the original object?
Create an eventlistener for the resizing element and resize alsoresizablevar1 & alsoresizablevar2.
What are you trying to do?
You'd better handle resizable.stop event and resize related objects manually based on the changed size of the original object. For example, I have implemented it in a simple project to resize page's sections manually by drag-and-drop.
$("#selector").resizable(
{
stop: function (e, ui)
{
var changedHeight = ui.size.height - ui.originalSize.height;
var changedWidth = ui.size.width - ui.originalSize.width;
// update related objects' size based on above values.
}
});