我有一个使用 Syncfusion Datagrid 的 MVC4 应用程序。在视图中,我有一个执行 jquery 函数的按钮(xfrButton):
$(document).ready(function () {
// Handle the clicking of the Request Transfer button
$('#xfrButton').click(function () {
// Initialize object to hold data grid
var GridObj = $find("AssetGrid")
// Initialize object to hold the filters the user selected in the grid
var gridData = Sys.Serialization.JavaScriptSerializer.serialize(GridObj._filters);
// Call controller action to process selected filters passing the filters variable (gridData)
$.post('<%: ResolveUrl("~/Step05_AssetsValidBUActiveCRS/RequestToTransfer/")%>', { select: gridData },
function (data) {
// If successful, call the Transfer Request View
var targetModel = Sys.Serialization.JavaScriptSerializer.serialize(data);
var targetURL = '~/Step05_TransferRequest/Index/?transferVM=' + targetModel.toString();
// var targetURL = '~/Step05_TransferRequest/Index/';
//TODO: Figure out a way to launch a new view upon success return from above statement
// Must pass the data returned from the above .post to the new controller action
// Current process just stays on the existing screen. Neither of the following work:
$(this).load(targetModel);
// window.location.href(targetURL);
}
, "json")
})
})
在 .post 中对 /Step05_AssetsValidBUActiveCRS/RequestToTransfer 的调用就像一个魅力,返回的数据是一个视图模型,其中包含我要启动的下一个视图的数据。唯一的问题是,无论我尝试做什么来启动下一个视图/操作(在本例中为 targetURL 中的 URL),当前视图和数据网格仍保留在浏览器中。
我可以再次单击 xfrButton 按钮,它会触发上述例程,该例程再次执行 .post 操作,但仍不会触发 targetURL 值。为什么 jquery 不启动新视图?
作为参考,这里是视图中的 Syncfusion 代码以及按钮:
<p>
<input id="xfrButton" type="submit" value="Request Transfer To" />
</p>
<%=Html.Syncfusion().Grid<AMSUtilityMVC4.ViewModels.Step05ListAssetsValidBUActiveCRSViewModel>("AssetGrid")
.Datasource(Model)
.EnableFiltering() /*Filtering Enabled*/
.EnableSorting() /*Sorting Enabled*/
.EnablePaging() /*Paging Enabled*/
.AllowResizing(true)
.Scrolling(scroll => scroll.Height(300).Width(1050))
.EnableScrolling()
.AllowSelection(true).RowsSelectionMode(RowsSelectionMode.Toggle)
.Column(cols =>
{
cols.Add(c => c.REMS).HeaderText("REMS").Width(75);
cols.Add(c => c.companyName).HeaderText("Company").Width(150);
cols.Add(c => c.LVID).HeaderText("LVID").Width(75);
cols.Add(c => c.entity).HeaderText("BU").Width(75);
cols.Add(c => c.locationDescription).HeaderText("Location Description").Width(150);
cols.Add(c => c.assetNumber).HeaderText("Asset No").Width(100);
cols.Add(c => c.majorCategory).HeaderText("Major Cat").Width(150);
cols.Add(c => c.minorCategory).HeaderText("Minor Cat").Width(150);
cols.Add(c => c.FACode).HeaderText("FA Code").Width(75);
cols.Add(c => c.description).HeaderText("Title").Width(150);
cols.Add(c => c.cost).HeaderText("Cost").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Format("{0:C}").Width(70);
cols.Add(c => c.nbv).HeaderText("NBV").Width(60);
cols.Add(c => c.GOC).HeaderText("GOC").Width(75);
cols.Add(c => c.FEIN).HeaderText("FEIN").Width(75);
cols.Add(c => c.datePlacedInService).HeaderText("In Service").Width(150);
cols.Add(c => c.vendorName).HeaderText("Vendor Name").Width(150);
cols.Add(c => c.accountingKey).HeaderText("Acct Key").Width(150);
cols.Add(c => c.locationKey).HeaderText("Location Key").Width(150);
cols.Add(c => c.state).HeaderText("State");
})
.ClientSideEvents(e => e.OnToolbarClickEvent("OnToolbarClickEvent"))
.ToolBar(tools =>
{
// Adding the custom toolbar items.
// Add(customItemtitle, customItemcaption, customItemCssClass)
tools.Add(GridToolBarItems.ExcelExport, "Excel Export")
.Add(GridToolBarItems.PDFExport, "PDF Export")
.Add(GridToolBarItems.Custom, "Transfer Request To", "RequestTransfer");
})
.Mappers(map =>{map.ExportExcelAction("GridExportToExcel")
.ExportPdfAction("GridExportToPDF");})
%>