javascript - Push one Row from Table 1 to table 2 and Splice the same row from Table 1 and vice-versa
问题描述
I have created a Method GetOpPriv() in the Home Controller which retrieves a JSON from a stored procedure. I have two tables on the Index View id='table1' & 'table2' I have Displayed the JSON values on 'table1' using JQuery Ajax. Now, I want to select rows from table1 and send those JSON values to table2 on click of a button. On click of 1st button, the value should be sent to table2 and the same value should be spliced from table1 and vice versa for the 2nd button. How can I do the Push and splice at the same time?
Home Controller
public JsonResult GetOpPriv()
{
using (MvcAssignmentEntities db = new MvcAssignmentEntities())
{
var op =( from data in db.OPERATION_PRIVILEGE()
select new
{
OperationName = data.OperationName,
PrivilegeName = data.PrivilegeName
}).ToList();
return Json(op, JsonRequestBehavior.AllowGet);
}
}
JQuery Ajax
<script type="text/javascript">
$(document).ready(function () {
debugger;
$.ajax({
url: "/Home/GetOpPriv",
type: "GET",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: function (data) {
var row = "";
$.each(data, function (index, item) {
row += "<tr><td>" + item.PrivilegeName + "</td>" + "<td>" + item.OperationName + "<td>";
});
$("#table1").html(row);
},
error: function (result) {
alert("Error");
}
})
});
</script>
<caption class="display-4">Available Privilege:</caption>
<table class="table-bordered" style="float: left" id="table1">
<thead>
<tr>
<th>Operation </th>
<th>Privilege Name</th>
</tr>
<tbody></tbody>
</table>
解决方案
推荐阅读
- ruby - 在我们中间的船员和冒名顶替者发电机不工作
- c++ - 字符串标记器、分隔符和使用文件输入制作对象
- python - Instagram 上的上传按钮不接受 Selenium send_keys
- flutter - 使用 Flutter BottomNavigationBar 重建相同的选项卡
- python - 绘制具有不同图例颜色的条形图
- python - Pythonic 方式来操作以逗号分隔的范围列表“1-5,10-25,27-30”
- android - PackageManager.getInstalledApplications(flag) 中标准应用程序的哪个标志?
- python - 如何使用 Python 或 R 对大型文本语料库(例如职位列表)进行聚类?
- laravel - 如何在 Laravel 6 中尝试/捕获 Swift_TransportException
- python-3.x - 重叠 X 标签