[英]How to Use dojo dnd in different scenarios
I am struggling with both the documentation of dojo and the information online to get to a solution for what i need, hoping for your help. 我正在努力阅读dojo的文档和在线信息,以寻求所需的解决方案,希望能为您提供帮助。
I am Implementing a DND from a grid to a source or a target: 我正在实现从网格到源或目标的DND:
new dojox.grid.enhanced.plugins.GridSource(dojo.byId("songForm"), {
isSource: false,
insertNodesForGrid: false
});
But i am not inserting anything in that target i am using the onDropGridRows
listner to create my own value which is a button and insert it in another div that has a normal dnd activated (calpanel) in it: 但是我没有在该目标中插入任何东西,
onDropGridRows
使用onDropGridRows
列表器创建了自己的值,该值是一个按钮,并将其插入到另一个具有正常dnd激活(div)的div中:
dojo.connect(formTarget, "onDropGridRows", lang.hitch(this,function (grid, rowIndexes) {
var s = grid.store,
row = rowIndexes[0];
// html.set(dom.byId("calPanel"), "<div id='calButton_" + s.getValue(grid.getItem(row), "elementid") + "'></div>");
// domConstruct.place("<div id='calButton_" + s.getValue(grid.getItem(row), "elementid") + "'></div>", "ElementsCalculator", "last");
new dijit.form.Button({
label: s.getValue(grid.getItem(row), "pagename") + ":" + s.getValue(grid.getItem(row), "col") + ":" + s.getValue(grid.getItem(row), "row"),
class: 'dojoDndItem',
onClick: function () {
}
}).placeAt("calPanel");
if (source != null) {
source.destroy();
}
source = new dojo.dnd.Source("calPanel", {
copyOnly: false
});
}
two problems i am facing here : 我在这里面临的两个问题:
1) the songForm panel which should be only a target from a grid is also running as a target from a regular dnd source, how can i stop that from happening ? 1)应该仅是网格目标的songForm面板也正在作为常规dnd源的目标运行,我如何才能阻止这种情况的发生?
2) the listener I implemented as shown below is listening for any DND action not just the node i supplied do you have any idea why? 2)如下所示实现的侦听器正在侦听任何DND动作,而不仅仅是我提供的节点,您知道为什么吗?
dojo.connect(source, "onDndDrop", lang.hitch(this,function (grid, rowIndexes) {}
An example based on my earlier comment... 基于我之前的评论的示例...
checkAcceptance: function (source, nodes) {
if (source intanceof yourGridClass) {
return true;
}
// You may need to use this.inherited(arguments) here
return false;
}
checkAcceptance
would go in your songForm
code. checkAcceptance
将输入您的songForm
代码中。
For your second question, I've found that to be the case as well. 对于第二个问题,我发现情况也是如此。 I don't know why it is, but it's very easy to deal with by using
checkAcceptance
and checkItemAcceptance
. 我不知道为什么,但是使用
checkAcceptance
和checkItemAcceptance
可以很容易地处理它。 checkItemAcceptance
is similar to checkAcceptance
. checkItemAcceptance
与checkAcceptance
相似。 The difference is you've already determined your target can accept something from the source, but now you're checking to see if the particular item you're dropping can be accepted. 区别在于您已经确定目标可以接受源中的某些内容,但是现在您要检查是否可以接受要删除的特定项目。
I hope this helps. 我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.