使用部分视图进行弹出,根据您的要求制作 UI,并将行详细信息作为模型传递给此部分视图。
你的表格 html 看起来像,
<tr id="@model.rowid">
<td>
sample
(<a onclick="RowDetails(@model.rowid)">Clickable</a>)
</td>
<td>
1/1/2012
</td>
<td>
</td>
</tr>
单击 Clicktable 时调用 javascript 函数,例如,
function RowDetails(RowId) {
$("#divDetails").load('/yourController/rowdetail', { id: RowId }).dialog({
modal: true,
title: "Row Detail",
height: 400,
width: 600,
buttons: {
"Ok": function () {
var isComplete = 0;
if ($("#rowComplete").is(":checked")) { isComplete = 1; }
$.get("/yourController/RowComplete", { id: RowId, isChk: isComplete }, function (d) {
$("#" + RowId).before(d).remove();
$("#" + RowId).hide().fadeIn('slow');
});
$(this).dialog('close');
}
}
});
}
和控制器一样,
public ActionResult rowdetail(int id)
{
// code to get row from databse
// return this row as object to partial view
return("partial view for row details", Object);
}
public ActionResult RowComplete(int id, int chk)
{
// code to update row from databse
// return this row as object
return("pass updated row", Object);
}