Javascript 可拖动的连接到可排序的
我希望能够将项目从一个Infrastics数据网格拖到另一个,同时目标网格中的项目也可以排序 不幸的是,我不能使用JSFIDLE,因为我不能使用那里的infragistics控件Javascript 可拖动的连接到可排序的,javascript,jquery,jquery-ui,jquery-ui-draggable,jquery-ui-sortable,Javascript,Jquery,Jquery Ui,Jquery Ui Draggable,Jquery Ui Sortable,我希望能够将项目从一个Infrastics数据网格拖到另一个,同时目标网格中的项目也可以排序 不幸的是,我不能使用JSFIDLE,因为我不能使用那里的infragistics控件 $("[id*=sourceGrid] [id*=dataTbl] tbody tr").draggable({ helper: "clone", revert: "invalid", connectToSortable: '[id*=destination]'
$("[id*=sourceGrid] [id*=dataTbl] tbody tr").draggable({
helper: "clone",
revert: "invalid",
connectToSortable: '[id*=destination]'
});
$("[id*=destinationGrid]").sortable({
cursor: 'move',
helper: fixHelperModified,
revert: true,
items: "[id*=container] [id*=dataTbl] tbody tr:not(.placeholder)",
receive: function (event, ui) {
var grid = $IG.WebDataGrid.find("destinationGrid");
$sentence = $(ui.item).find("td").eq(0).html();
var row = new Array(Math.floor((Math.random() * 100) + 1), $sentence, $order);
grid.get_rows().add(row);
}
});
问题是:当我将项目从sourceGrid拖放到destinationGrid时,我不想将Dragable放到新的网格中——我只想使用receive函数在网格中使用Dragable元素的值创建新行。现在,我同时得到了新创建的gridRow和删除的项。如何防止这种情况发生?您可以在beforeStop事件中捕获复制的项目
var newItem;
$(".list").sortable({
connectWith: ".list",
beforeStop: function (event, ui) {
newItem = ui.item;
},
receive: function(event,ui) {
$(newItem).doSomething();
}
});
此答案的参考和认可:您尝试过什么?如何将“helper”方法更改为原始方法,然后在拖放时删除()?抱歉,忘了提及。我需要“克隆人”的行为。我不想移动,但将项目从源克隆到目标,并且仍保留在源中。当我
remove()
接收事件中的ui.item时,我会删除sourceGrid中的原始行。这种行为非常奇怪,我不明白为什么ui.item是我拖动的原始元素,而不是克隆的占位符。您是否也尝试过将sourceGrid
设置为可排序的()?另外,在receive
事件中,您可以console.log ui.helper吗?