0
我試圖讓MVCGrid的選擇行和使用partialview在模態對話框顯示的細節。MVC4的DetailView從GridMvc.selectedData
我通過AJAX獲得所選擇的行:
$(document).ready(function(){
var selectedRow;
$(document).on('click', '.grid-mvc', function() {
pageGrids.PersonGrid.onRowSelect(function (e) {
// $.prompt(e.row.ID);
SendData(e.row);
});
});
});
在「SendData'功能是:
function SendData(i) {
var data= i.ID;
$.ajax({
url: '/Home/Person',
contentType: "application/html; charset=utf-8",
type: "GET",
data: { "id": daten },
dataType: "html"
, success: function() {
ShowPersonDetails(data);
}
});
}
和ShowPersonDetails(數據)是這樣的:
function ShowPersonDetails(data) {
$(document).ready(function() {
$('#PersonDiv').load("Person?id=" + data);
$("#PersonDiv").prompt(
$("#PersonDiv").html(),
{
title: "some title",
buttons: { OK: 'true', Abbruch: 'false' },
position: { width: 800, height: 600 }
});
});
}
控制器:
[HttpGet]
public ActionResult Person(int id)
{
var pS = new DbAccess(MvcApplication.Connection).GetUserData(id);
var p = new Person();
if (pS.Rows.Count < 0)
{
return PartialView("Person");
}
p.Alter = pS.Rows[0].ItemArray[0].ToString();
p.Nachname = pS.Rows[0].ItemArray[5].ToString();
return PartialView("Person", p);
}
任何意見將是太好了!
問候 PP