JQuery从两个表中拖放

JQuery Drag and Drop from two tables

本文关键字:两个 拖放 JQuery      更新时间:2023-09-26

我需要实现从一个表到另一个表的拖放功能,反之亦然。

这是我的功能,我可以将交易获取到特定的IBAN号码,我还有同样的功能,可以检索隐藏的用户交易。

   function getAllTransactions(iban) {
    var iban = $("#ibanSelection").val();
    var username = $("#hiddenusername").val();
    var url = 'http://localhost:64300/api/BankAccountApi/GetUserTransaction/?iban=' + iban;
    var table = "<table id='"table1'">";
    if ((username != "") && (iban !="")) {
        $.getJSON(url, function (data) {
            table += "<tr class='"ibanSelection'">";
            table += "<th>My IBAN</th>";
            table += "<th>Send to IBAN</th>";
            table += "<th>Transfer Date</th>";
            table += "<th>Amount</th>";
            table += "</tr>";
            $.each(data, function (key, val) {
                table += "<tr class='"draggable_tr'">";
                table += "<td>" + val.My_Iabn + "</td>";
                table += "<td>" + val.Iban_To + "</td>";
                table += "<td>" + val.Transfer_Date + "</td>";
                table += "<td>" + val.Amount_Transferd + "</td>";
                table += "</tr>";
            });
            table += "</table>";
            $("#divResult2").html(table);
        }); 
    }
}

只需使用jQueryUI排序功能。以下是完整的示例+文档。非常简单。

这个例子也展示了你的情况:

http://jqueryui.com/sortable/#connect-列出