在我的视图中,我有一个网格和网格上方的复选框。选中复选框后,我无法刷新网格。我正在使用Grid.MVC。有人可以帮我这个。
Index.cshtml
@(Html.Grid(Model.RequestDetail).Named("RequestGrid").Columns(columns => { columns.Add(c => c.RequestNumber).Titled("Request Number").Sanitized(false).Encoded(false).RenderValueAs(o => Html.ActionLink(o.RequestNumber, "", new { requestNumber = o.RequestNumber }, new { @class = "anchorDetail" }).ToHtmlString()); columns.Add(c => c.RequestType).Titled("Request Type"); columns.Add(c => c.RequestedBy).Titled("Requested By"); columns.Add(c => c.CreatedDate).Titled("Created").Format("{0:d-MMM-yyyy}"); columns.Add(c => c.AssignedTo).Titled("Assigned To"); columns.Add(c => c.DueDate).Titled("Due Date").Format("{0:d-MMM-yyyy}"); columns.Add(c => c.RequestStatus).Titled("Request Status"); columns.Add(c => c.CompletedDate).Titled("Completed Date").Format("{0:d-MMM-yyyy}"); }).WithPaging(10).Sortable())
脚本:
function ViewAssignedRequests() {
var userName = "@ViewData["Name"]";
var isChecked;
if (document.getElementById('chkAssign').checked) {
isChecked = true;
}
else {
isChecked = false;
}
$.ajax({
type: "POST",
url: "/ViewRequestDetails/GetAssignedList",
contentType: "application/json; charset=utf-8",
data: "{ 'userName' : '" + userName + "', 'isChecked' : '" + isChecked + "' }",
datatype: "json",
success: function () {
$('.grid-mvc').gridmvc();
$('#RequestGrid').reload();
//pageGrids.RequestGrid.refreshFullGrid();
},
error: function () {
alert("Dynamic content load failed.");
}
});
}
我的控制器直接返回整个视图
[HttpPost]
public ActionResult GetAssignedList(string userName, bool isChecked)
{
RequestDetails reqObj = new RequestDetails();
reqObj.RequestDetail = viewDAObj.PopulateRequestAssignedGrid(userName, isChecked);
return View("Index", reqObj);
}