我得到了包含表的主视图,在行上单击 ajax 请求将被发送。
$.ajax({
url: `/home/setViewBag/${id}`,
type: "get",
success: function (msg) {
$("#modal").html("");
$("#modal").append(msg);
modal.style.display = "block";
},
});
“SetViewBag”
[HttpGet]
[Route("setViewBag/{id}")]
public async Task<ActionResult> SetViewBag(int id)
{
ViewBag.Id = id;
return View("AjaxGrid");
}
AjaxGrid.cshtml
@using NonFactors.Mvc.Grid
@Html.AjaxGrid(
Url.Action("TestMethod", "Main", new { Id = ViewBag.Id }))
“测试方法”
[HttpGet]
[Route("TestMethod/{id}")]
public async Task<ActionResult> TestMethod(int id)
{
return PartialView(await _service.Get(id));
}
问题:Ajax 请求附加到我的模态新 div 没有 TABLE
<div class="mvc-grid" data-url="/main/testMethod/1"></div>
正如您在图像上看到的,模态是空的
模态应该包含渲染表
@Html.Grid(Model).Build(columns =>
{
columns.Add(model => model.Id).Titled("Id");
columns.Add(model => model.Name).Titled("Name");
}).Pageable(pager =>
{
pager.PageSizes = new Dictionary<Int32, String> {{0, "All"}, {1, "1"}, {20, "20"}};
pager.ShowPageSizes = true;
pager.PagesToDisplay = 3;
pager.CurrentPage = 1;
pager.RowsPerPage = 1;
})
应用程序:Asp.Net CORE 3.1 MVC-Grid v6.2.4