我需要在带有 asp.net mvc 的项目中打开一个按钮触发的弹出窗口。我使用 Ajax 发送一个参数并将部分视图设置为模态的主体。数据进来,枢轴网格被创建,但枢轴网格事件不起作用。当我单击弹出窗口中枢轴网格上的分页或排序时,文本“正在加载”并且它永远不会消失。我在做某处缺少的东西吗?我在显示弹出窗口时调用了 AdjustControl 方法,但它不起作用。它占用了我很多时间,但我仍然找不到解决方案。我请求你的支持。
按钮
<button type="button" class="btn btn-sm btn-block btn-primary" data-toggle="modal" data-target="#modalView" onclick="RetrieveStokMiktari('@Url.Action("RetrieveStokMiktari", "AnaBayi")')">
<i class="fas fa-list"></i> Stok Miktarını Getir
</button>
带参数的 Ajax 调用
function RetrieveStokMiktari(url) {
debugger;
var token = $('input[name="__RequestVerificationToken"]').val();
var kaliteId = $('#kaliteDropdown').val();
var kaliteAdi = $('#kaliteDropdown').find(':selected').text();
var obj = { kaliteId: kaliteId, kaliteAdi: kaliteAdi };
AjaxCall(url,
obj,
"GET")
.done(
function (data) {
$("#modalView .modal-body").html(data);
$("#modalView .modal-dialog");
$("#modalView .modal-title").text('Shipment Files');
$("#modalView").modal("show");
$("#modalView").on("shown.bs.modal", function () { PivotGrid1.AdjustControl(); });
}).fail(function (error) {
alert(error.StatusText);
toastr.error("Hata : " + error.StatusText, "Hata");
});
}
自定义ajax方法
function AjaxCall(url, data, type) {
return $.ajax({
url: url,
type: type ? type : 'GET',
data: data,
contentType: 'application/json'
});
}
ASP.NET MVC 控制器和操作
public ActionResult RetrieveStokMiktari(int kaliteId, string kaliteAdi)
{
try
{
IEnumerable<HrkHaliStok> list = new List<HrkHaliStok>();
if (Session["Username"] != null)
{
UserTnmKullaniciViewModel user = (UserTnmKullaniciViewModel)Session["Username"];
string filtre = FiltreOku(kaliteId, Convert.ToInt32(user.FIR_ID));
using (MrnSiparisEntities mrnSiparisEntities = new MrnSiparisEntities())
{
string sql = " SELECT KALITE, EBAT, DESEN, RENK, ISNULL(SUM(MIKTAR), 0) AS MIKTAR " +
" FROM HRK_HALI_STOK " +
" WHERE (KALITE = @kaliteAdi) " + filtre +
" GROUP BY KALITE, EBAT, DESEN, RENK ";
list = mrnSiparisEntities.Database.SqlQuery<HrkHaliStok>(sql, new SqlParameter("@kaliteAdi", kaliteAdi)).ToList();
}
}
return PartialView("StokMiktarBilgisi", list);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
部分视图
@using System.Web.UI.WebControls
@model IEnumerable<MerinosWebSiparis.Models.HrkHaliStok>
@{
Layout = null;
}
@Html.DevExpress().PivotGrid(settings =>
{
settings.Name = "PivotGrid1";
settings.OptionsCustomization.AllowDrag = true;
settings.OptionsView.ShowFilterHeaders = true;
settings.Width = Unit.Percentage(100);
settings.Fields.Add(field =>
{
field.Area = PivotArea.RowArea;
field.FieldName = "KALITE";
field.Caption = "KALITE";
});
settings.Fields.Add(field =>
{
field.Area = PivotArea.RowArea;
field.FieldName = "DESEN";
field.Caption = "DESEN";
});
settings.Fields.Add(field =>
{
field.Area = PivotArea.RowArea;
field.FieldName = "RENK";
field.Caption = "RENK";
});
settings.Fields.Add(field =>
{
field.Area = PivotArea.DataArea;
field.FieldName = "MIKTAR";
field.Caption = "MIKTAR";
});
settings.Fields.Add(field =>
{
field.Area = PivotArea.ColumnArea;
field.FieldName = "EBAT";
field.Caption = "EBAT";
});
}).Bind(Model).GetHtml()
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.Editors },
new Script { ExtensionSuite = ExtensionSuite.GridView },
new Script { ExtensionSuite = ExtensionSuite.NavigationAndLayout }
)
@Html.DevExpress().GetStyleSheets(
new StyleSheet { ExtensionSuite = ExtensionSuite.Editors },
new StyleSheet { ExtensionSuite = ExtensionSuite.GridView },
new StyleSheet { ExtensionSuite = ExtensionSuite.NavigationAndLayout }
)