如何在网格列单击&上调用Action方法在Modal Popup中显示数据? [英] How do I call Action method on grid column click & display data in Modal Popup?
问题描述
我正在使用网格:
I am using Web Grid:
webGrid.Column("", format:
@<text>
<a class="edit-user display-mode">
<img src="@Url.Content("~/assets/images/Edit.gif")"></a>
</text>,style: "col1Width" , canSort: false),
点击此编辑列我正在调用此脚本获取我想要编辑的记录的ID:
On click of this Edit Column i am calling this script to get the ID of the record i want to
<script type="text/javascript">
$('.edit-user').on('click',function(){
var tr = $(this).parents('tr:first');
var BranchContactID = tr.find("#hdnBranchContactID").val()
alert(BranchContactID);
});
</script>
现在点击此编辑我希望调用一个Action方法,它将获得使用我从脚本获取的id的记录的详细信息和将显示模式弹出窗口。
Now on click of this Edit i want an Action method to be called which will get the details of the record using the id i get from the script and "a modal popup should get displayed."
@using (Ajax.BeginForm("AddBranchContact", new AjaxOptions { HttpMethod = "POST", OnSuccess = "$('#myModal1').modal('hide');", UpdateTargetId = "myTable" }))
{
<div id="myModal1" class="modal fade" role="dialog">
}
推荐答案
(' 。edit-user')。on(' 单击, function (){
var tr =
('.edit-user').on('click',function(){ var tr =
( this )。parents(' < span class =code-string> tr:first');
var BranchContactID = tr.find( #hdnBranchContactID)。val()
alert(BranchContactID);
});
< / script>
(this).parents('tr:first'); var BranchContactID = tr.find("#hdnBranchContactID").val() alert(BranchContactID); }); </script>
现在点击此编辑我希望调用一个Action方法,它将获得使用我从脚本获取的id的记录的详细信息和将显示模式弹出窗口。
Now on click of this Edit i want an Action method to be called which will get the details of the record using the id i get from the script and "a modal popup should get displayed."
@using (Ajax.BeginForm("AddBranchContact", new AjaxOptions { HttpMethod = "POST", OnSuccess = "
('#myModal1')。modal('hide');,UpdateTargetId =myTable }))
{
< div id = myModal1 class = modal fade role = 对话框 >
}
('#myModal1').modal('hide');", UpdateTargetId = "myTable" })) { <div id="myModal1" class="modal fade" role="dialog"> }
这篇关于如何在网格列单击&上调用Action方法在Modal Popup中显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!