我在用模态分页渲染gridview时遇到问题。每当我单击其他页面时,它根本不会呈现模式。仅带有下一页格式的文本。目前,这些是我只能显示的内容,但是如果您需要查看问题的屏幕截图或控制器,我将尝试将其发布。
使分页正常工作没有问题。唯一的是视图。我使用#modal-container
视图中的操作链接调用INDEX
,然后在其中显示带有gridview数据。问题是,当我单击数据的下一页时,尽管它转到下一页,但它取消呈现整个页面的所有CSS。只是精简的格式化文本。如何只更新gridview?
@Html.ActionLink("Transaction History", "TransactionHistory", "AccountBalance", new { accountID = item.AccountID, page = 1, pageSize = 15 },
htmlAttributes: new
{
onclick = "GetPlayersDetails('" + item.AccountID + "')",
data_target = "#modal-container",
data_toggle = "modal",
@class = "btn btn-xs btn-flat btn-warning"
}).If("AccountBalance", "TransactionHistory")
这是onclick AJAX
代码:
function GetPlayersDetails(accountID) {
console.log('asdasd');
$.ajax({
url: '@Url.Action("TransactionHistory")', //"/Player/GetPlayersByTeam",
dataType: "html",
data: { accountID: accountID },
type: "GET",
error: function (xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
toastr.error(err.message);
console.log('error');
},
success: function (data) {
$('#qweqwe').html(data);
console.log('success');
}
});
}
这是偏视图模式:
<table id="qweqwe" class="table table-hover table-bordered table-striped text-sm ordertable">
<thead>
<tr>
<th width="35%">Transaction Date</th>
<th>Notes</th>
<th>Amount IN</th>
<th>Amount Out</th>
</tr>
</thead>
<tbody id="checkboxTable">
@foreach (var item in Model.History)
{
<tr id="tableRow" class="text-center">
<td><br />@Html.DisplayFor(modelItem => item.TransactionDate)</td>
<td><br />@Html.DisplayFor(modelItem => item.Notes)</td>
<td><br />@Html.DisplayFor(modelItem => item.AmountIn)</td>
<td><br />@Html.DisplayFor(modelItem => item.AmountOut)</td>
<td class="text-center actionTD hidden">
</td>
</tr>
}
</tbody>
</table>
这是模态上的寻呼机:
@Html.PagedListPager(Model.History, page => Url.Action("TransactionHistory",
new
{
accountID = ViewBag.accountID,
page = page
}),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new PagedListRenderOptions
{
DisplayPageCountAndCurrentLocation = true,
DisplayItemSliceAndTotal = true,
ItemSliceAndTotalFormat = "Total Records: {2}",
LinkToFirstPageFormat = "First",
LinkToPreviousPageFormat = "Previous",
LinkToNextPageFormat = "Next",
LinkToLastPageFormat = "Last"
},
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "Get",
UpdateTargetId = "qweqwe"
}))
这是我的控制器执行的操作:
public ActionResult TransactionHistory(int accountID, int? page)
{
page = page == null ? 1 : page;
DateTime startDate = Convert.ToDateTime("10-26-2018");
DateTime endDate = Convert.ToDateTime("10-29-2018");
var list = BankAccountManagementBusinessLogic.GetDataUpdate(accountID, startDate, endDate, (int)page, pageSize);
int totalRows = list.Count() > 0 ? (int)list.First().TotalRows : 0;
var mylist = new StaticPagedList<spGetAccountTransactionHistory_Result>(list, (int)page, pageSize, totalRows);
TransactionHistorySearchModel searchModel = new TransactionHistorySearchModel();
TransactionHistoryViewModel model = new TransactionHistoryViewModel(searchModel, mylist);
ViewBag.accountID = accountID;
return PartialView(model);
}
现在,这些代码起作用了。显示模态和gridview。问题在于,当转到下一页时,整个页面的css消失了,仅显示了第二页的格式化文本。我昨天无法为此找到解决方案,希望能有所帮助。谢谢