Hello,
Can I have context menu options popped when I drag and drop on an element. Basically I want to give user an option of copy files or move files when user drag and drops.
hello,
Menu has showContextMenu(x,y) that allows to show context menu in a certain position. Using onDrag event handler you can apply the following approach:
when onDrag is occurs, you should:
1) save source and target items ids
2) show context menu
3) deny drag
When menu item is clicked, you should enable/disable mercy drag and hide menu:
menu = new dhtmlXMenuObject(null,“standard”);
menu.renderAsContextMenu();
menu.attachEvent(“onClick”,onButtonClick);
var showMenu = 1;
var target_id = 0;
var source_id = 0;
tree.attachEvent(“onDrag”,function(sid,tid){
target_id = tid;
source_id = sid
if(!showMenu) return true
menu.showContextMenu(X,Y)
return false
})
function onButtonClick(menuitemId,type){
if(menuitemId==“copy”) tree.enableMercyDrag(true)
else tree.enableMercyDrag(false)
showMenu = 0
tree.moveItem(source_id,“item_child”,target_id)
menu.hideContextMenu()
showMenu = 1
}
Thanks for the solution. I have used “moveRowTo” function to move or copy data. If the user selects copy then we need to insert data into database while if user selects move we just need to update the database. I tried using “setOnBeforeUpdateHandler” and manually set copy as true (using code - projDetailsGrid.setUserData("", “copy”, “true”)). But on the server if I perform request.getParameter(“copy”) it give me null. How should I inform servlet about the operation performed( copy or move).
Thanks again for continued support. Appreciate it.
setOnBeforeUpdateHandler is called too late to send userdata to the server.
You can use onDrag event instead of it.
I have performed this command at the beginning “projDetailsGrid.setUserData(”",“sample”, “1”);". Still the servlet cannot recognize the value of sample. It returns null.
Code snippet
projDetailsGrid.setUserData("",“sample”, “1”);
…
…
… Some thing goes here*
…
…
myDataProcessor1 = new dataProcessor(“xmlJsps/xml_feed_project.jsp?action=data”);
myDataProcessor1.setUpdateMode(“cell”);
myDataProcessor1.enableUTFencoding(true);
myDataProcessor1.setTransactionMode(“POST”);
myDataProcessor1.enableDebug(true);
and on the server side when i perform
String sample = request.getParameter(“sample”);
it give me o/p as null
What can be the reason?
You can check using dataprocessor_debug.js what values are sent to server.
Moreover userdata is set only for a certain row:
projDetailsGrid.setUserData(rowId,“sample”, “1”);