我在尝试渲染Infragistics网格时遇到错误,我无法找到原因,谷歌搜索,搜索论坛等... eval代码中第1423行第16行的未处理异常 '0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法' igGrid'发生在'运行时生成的文件中,称为eval代码: $(function(){$(' #FileContent')。igGrid({dataSource:{" Records":[{" Id":0,&#34 ;领域......等 我尝试使用集合而不是GridModel,结果相同。 我的错误在哪里? Infragistics需要我的钱来回答问题...... 我正在使用Visual Studio 2017,它是一个ASP.NET MVC 4项目。控制器响应正常,当客户端尝试呈现网格时发生错误。
请帮忙!
谢谢!
我的模特:
public class SasFileViewModel
{
public int Id { get; set; }
[Display(Name = "File Name")]
public string Name { get; set; }
[Display(Name = "File Path")]
public string Path { get; set; }
public string Header { get; set; }
public virtual List<SasFileLine> Content { get; set; }
}
public class SasFileLine
{
public int Id { get; set; }
public List<string> Fields { get; set; }
}
public class SasFileListViewModel
{
[Display(Name = "File Id")]
public int SelectedFileId { get; set; }
public SelectList SasFiles { get; set; }
}
我的控制器:
public ActionResult SelectedSasFile(int selectedFileId)
{
if (!ModelState.IsValid)
return View();
var model = GetSasFile(selectedFileId);
return PartialView(model);
}
private GridModel GetSasFile(int selectedFileId)
{
var sasFile = new SasFileViewModel()
{
Id = 0,
Content = new List<SasFileLine>()
};
var sasFileDtoList = SasAsp.BusinessLibrary.SasFile.GetSasFiles().ToList();
if (sasFileDtoList != null && sasFileDtoList.Count > 0)
{
var dto = sasFileDtoList.Where(x => x.Id == selectedFileId).First();
var fileName = Path.Combine(dto.Path, dto.Name);
var sasFileDto = SasAsp.BusinessLibrary.SasFile.GetSasFile(fileName);
sasFile = MapToModel(sasFileDto); // just maps data transfer objects to the model
}
var fileContentGrid = CreateGrid(sasFile);
return fileContentGrid;
}
private static GridModel CreateGrid(SasFileViewModel sasFile)
{
var fileContentGrid = new GridModel
{
ID = "FileContent",
DataSource = sasFile.Content.ToList().AsQueryable(),
AutoGenerateColumns = true
};
return fileContentGrid;
}
我对网格的部分视图:
@using Infragistics.Web.Mvc
@using SasAspMvc.Models
@model GridModel
<link href="~/IgniteUI/css/structure/infragistics.css" rel="stylesheet" />
<link href="~/IgniteUI/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
<script type="text/javascript" src="~/IgniteUI/js/infragistics.core.js"></script>
<script type="text/javascript" src="~/IgniteUI/js/infragistics.lob.js"></script>
@(Html.Infragistics().Grid(Model))
我的索引视图:
@using SasAspMvc.Models
@model SasFileListViewModel
@{
ViewBag.Title = "SAS Files";
}
<h2>@ViewBag.Title.</h2>
@{Html.RenderPartial("SasFileList", Model); } // This renders a combo box with a list of existing files too choose from
<table id="FileContent" style="white-space: pre-line"></table>
<script type="text/javascript">
$(document).ready(function () {
$("#SelectedFileId").on("change", function () {
var id = $('#SelectedFileId').val();
showSelectedFile(id);
});
});
function showSelectedFile(id) {
$("#FileContent").html('<b>Please wait...</b>');
//debugger;
$("#FileContent").load('@(Url.Action("SelectedSasFile", "SasFiles", null, Request.Url.Scheme))?selectedFileId=' + id);
}
答案 0 :(得分:0)
您应该在Ignite UI的core
和lob
脚本之前包含jQuery和jQuery UI。
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>