我创建了一个 div 并尝试像 loader.show() 一样调用 Jquery。但不确定当我对 mvc webgrid 进行分页或排序时如何触发它?
我的网络网格:
<div id="grid">
@{
var grid = new WebGrid<MemberSearch>(ajaxUpdateContainerId: "grid",
rowsPerPage: Model.PageSize, defaultSort: "LastName");
grid.Bind(Model.Member, rowCount: Model.TotalRows, autoSortAndPage: false);
// NOTE: I've created another html helper to allow a server-paged grid to be rendered in one call (complete with compiler type inference) as shown below
//var grid = Html.ServerPagedGrid(Model.Products, Model.TotalRows, rowsPerPage: Model.PageSize);
}
@grid.GetHtml(tableStyle: "webgrid",
headerStyle: "webgrid-header",
footerStyle: "w-footer",
alternatingRowStyle: "webgrid-alternating-rows",
columns: grid.Columns(
grid.Column(format: @<text>@Html.ActionLink("Edit", "Edit", new { Id = item.Id }) </text>),
grid.Column("fullname", header: "Name", format: @<text>@item.fullname</text>),
grid.Column("Email", header: "Email", format: @<text>@item.Email</text>),
grid.Column("companyname", header: "Company", format: @<text>@item.companyname</text>),
grid.Column("regDate", header: "Registration Date", format: @<text>@item.regDate</text>),
grid.Column("country", header: "Country", format: @<text>@item.country</text>),
grid.Column("modifiedDate", header: "Profile Modified", format: @<text>@item.modifiedDate</text>),
grid.Column("ciscontactid", header: "CIS ID", format: @<text>@item.ciscontactid</text>)
)
)
</div>
在您的文档中,准备好添加以下内容:
$('thead > tr > th > a[href$="sort"]').click(function () {
loader.show()
});
这将选择 WebGrid getHtml 为您生成的 th 标签和 a 标签。 这将在网格排序时进行处理。