我在Column中获得了价值,以下是代码。
grid.Column(columnName: "Name", header: "Name",format: @<text>
<span id="Name">@item.Name</span></text>, canSort: false),
想在我在删除按钮上调用的函数中使用此值
function DeleteEnterpriseID() {
var checkID = $(".edit-mode:checked").map(function () {
return this.value;
}).toArray();
alert(checkID.join(","));
if (confirm("Are you sure you want to delete?") == true) {
var url = "@Url.Action("DeleteEnterpriseIdDetails")";
var pname = $('#Name').val(); //// Here I want that value from the clicked row so that I can pass that to controller.
alert(pname);
$.ajaxSetup({ cache: false });
$.post(url, { Pname: pname, EnterpriseID: checkID.join(",") })
.success(function (response) {
if (response != null && response.success) {
alert(response.responseText);
window.location.href = response.newurl;
} else {
alert(response.responseText);
}
})
.error(function (response) { alert("error"); });
}
else {
return false;
}
}
但是我从点击的行获取了Name的空白值。 请帮助。
答案 0 :(得分:1)
应该是:
var pname = $('#Name').text();
因为它是span
标记而不是输入元素。 val()
适用于输入元素。