gpt4 book ai didi

c# - WebGrid 分页不工作

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:59 28 4
gpt4 key购买 nike

我有一个下拉列表和按钮控件,单击按钮时我绑定(bind)了 WebGrid,它工作正常,加载时网格将为空,但绑定(bind)后网格分页不起作用,下面是我的代码

@using (Html.BeginForm("EmpLog", "Labels", FormMethod.Post))
{
@Html.DropDownListFor(x => x.SelectedValue, Model.Values, "----Select----", new { id = "ddlName", @class = "form-control col-md-6" })
<input type="submit" value="Search" id="btnSearch" class="btn btn-default" />

@{
var gridview = new WebGrid(source: Model.LstLog, rowsPerPage: 20, ajaxUpdateContainerId: "grid", canSort: false);
}

@if (Model.Lst != null)
{
@gridview.GetHtml(
htmlAttributes: new { id = "gridlogs" },
fillEmptyRows: false,
alternatingRowStyle: "alternate-row",
headerStyle: "grid-header",
footerStyle: "grid-footer",
selectedRowStyle: "grid-selected-row",
rowStyle: "grid-row-style",
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: new[] {
gridview.Column("View", header: null, style: "click_able", format: @<text><a href="javascript:ViewFullDetails('@item.Id');">View</a></text>, canSort: false),
gridview.Column("JoinDate",header: "Join Date"),
gridview.Column("DeptName",header: "Dept Name"),
gridview.Column("Project",header: "Project")
}
)}
}

[HttpGet]
public ActionResult EmpLog()
{
model.Values = GetDDLInfo();
return View();
}

[HttpPost]
public ActionResult EmpLog()
{
model.Values = GetDDLInfo();
model.LstLog= GetLogInfo();
return View(model);
}

我对 WebGrid 不够好,请帮助我在其中应用分页。

最佳答案

我添加了下面的代码来工作分页

$('th a, tfoot a').click(function () {
$('form').attr('action', $(this).attr('href')).submit();
return false;
});

关于c# - WebGrid 分页不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50619134/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com