我已经将一个 mvc3 项目升级为 mvc4 项目,并将目标框架从 .NET 4.0 更改为 .NET 4.5(我不知道是否重要)。
现在,无论我在哪里使用 webgrid 助手,分页都完全被破坏了。实际上,更新请求被发送了 4 次,并且以“displayClient”为 Id 的元素完全从 html 文档中删除。
这是我的源代码的几行:
@{
var grid = new WebGrid(canPage: true, canSort: true, ajaxUpdateCallback: "UpdateWebGridClient", ajaxUpdateContainerId: "displayClient", rowsPerPage: Model.RowPerPageClientId);
grid.Bind(Model.ClientList, rowCount: Model.ClientNumber, autoSortAndPage: false);
@grid.GetHtml(
htmlAttributes: new { id = "grid", @class = "clientTable" },
rowStyle: "odd",
alternatingRowStyle: "even",
footerStyle: "footerWebGrid",
mode: WebGridPagerModes.All,
numericLinksCount: 10,
columns: grid.Columns(
grid.Column("Id", SUResources.Admin.ClientRef, style: "ref"),
grid.Column("FullName", SUResources.Admin.ClientFullName, style: "name"),
grid.Column("Town", SUResources.Admin.ClientTown, style: "town"),
grid.Column("Country", SUResources.Admin.ClientCountry, style: "country"),
grid.Column("Email", SUResources.Admin.ClientEmail, style: "email"),
grid.Column("PurchasedPicture", SUResources.Admin.ClientPurchasedPicture, style: "purchasedPicture"),
grid.Column("Ca", SUResources.Admin.ClientRevenue, style: "ca"),
grid.Column(
style: "first-icon icons",
format: (item) => Ajax.ActionLink(
" ",
"ClientInformation",
new { clientId = item.Id },
new AjaxOptions
{
HttpMethod = "Get",
UpdateTargetId = "showClientInformation",
InsertionMode = InsertionMode.Replace
},
new
{
@class = "record"
}
)
),
grid.Column(
style: "icons",
format:
@<text>
@Html.ActionLink(" ", "Index", "SendMail", new { CustomerId = item.Id }, new { @class = "green-mail" })
</text>
),
grid.Column(
style: "icons",
format:
@<text>
@if (item.StatusId == (short)Shootus.Domain.EnumTypes.CustomerState.Active)
{
<a onclick="ChangeCustomerStatus(this);" data-customer-id="@item.Id"> <img alt="" title="@SUResources.Admin.ClientEditionActiveUser" src="/Areas/Admin/Content/Images/Icons/ico-client-active-account.png"/></a>
}
else
{
string CustomerCurrentStatus = SUResources.Admin.ClientEditionBannedUser;
CustomerCurrentStatus = (item.StatusId == (short)Shootus.Domain.EnumTypes.CustomerState.NotValidated) ? SUResources.Admin.ClientEditionEmailNotValidatedUser : CustomerCurrentStatus;
CustomerCurrentStatus = (item.StatusId == (short)Shootus.Domain.EnumTypes.CustomerState.TurnedOff) ? SUResources.Admin.ClientEditionUnactiveUser : CustomerCurrentStatus;
<a onclick="ChangeCustomerStatus(this);" data-photographer-id="@item.Id"> <img alt="" title="@CustomerCurrentStatus" src="/Areas/Admin/Content/Images/Icons/ico-client-inactive-account.png"/></a>
}
</text>
),
grid.Column(
style: "icons",
format: @<text>
@Html.ActionLink(" ", "Delete", new { Id = item.Id }, new { @class = "delete" })
</text>
)
)
);
}
<div class="dot-line">
</div>
<div class="pager client-line-pager">
@grid.Pager()
</div>
webgrid 中的默认分页器使用 css 属性显示隐藏。
我在生成的 html 中看到有一些新的属性,如表上的 data-swhgajax、data-swhgcallback 和为寻呼机生成的代码:data-swhgcontainer、data-swhglnk、...
我使用 jQuery.ajaxPrefilter 来处理来自页面中外部表单的一些额外数据。
有没有人有同样的问题,他解决了吗?关于这个问题的起源的想法?
感谢您花时间阅读这篇文章,我希望有人可以帮助我:-(