【发布时间】:2015-10-09 13:21:18
【问题描述】:
我正在使用 Ienumerable 而不是 Json Data 将数据绑定到 Kendo 网格。
我收到此错误: 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串长度超过 maxJsonLength 属性设置的值。
即使尝试在 web.config 中设置低于 maxjsonlength
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647" />
</webServices>
</scripting>
这是我的剑道网格
@model IEnumerable<AssetTrackingSystem.Model.SampleDetailsSummary>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns=>
{
columns.Bound(p => p.JobNumber).Title("Job Number").Width("125px");
columns.Bound(p => p.SampleNumber).Template(@<text></text>).ClientTemplate("<a href='" + Url.Action("SampleDetails", "JobDetails", new { AssetId = "#=AssetId#" }) + "'>#=SampleNumber#</a>").Title("Sample Number").Width("125px");
columns.Bound(p => p.SampleType).Title("Sample Type").Width("125px");
columns.Bound(p => p.ServiceVendor).Title("Service Vendor").Width("125px");
columns.Bound(p => p.BarCode).Title("Barcode").Width("125px");
columns.Bound(p => p.LocationName).Title("Current Location").Width("125px");
columns.Bound(p => p.GPS).Title("GPS").Width("125px");
}).Pageable().Sortable().Scrollable(scr => scr.Height(scroolheight)).Filterable().Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5)).DataSource(dataSource => dataSource
.Ajax()
.PageSize(50)
.ServerOperation(false)
.Model(model => model.Id(p => p.AssetId))
)
这是我的控制器操作方法
public ActionResult CompanyAssets()
{
Guid CompanyId = new Guid(Request.Params["CompanyId"].ToString());
int GPSOnly = int.Parse(Request.Params["Gps"]);
//bool GPSOnly = GPSOnly1.Equals("1") ? true : false;
JobDetailsRepository rep = new JobDetailsRepository(Session["Connectionstring"].ToString());
// IList<AssetDetails> assetinfo = rep.GetAssetsByCompanyId(CompanyId);
IList<SampleDetailsSummary> assetinfo = rep.GetAllSamplesByCompanyId(CompanyId, GPSOnly);
CompanyRepository cmprep = new CompanyRepository(Session["Connectionstring"].ToString());
// IList<CompanyInfoSummary> s = cmprep.GetLocationsByCompanyId(CompanyId);
var company = cmprep.GetCompany(CompanyId);
ViewBag.companyName = company.CompanyName;
var model = assetinfo;
return View(model);
}
任何人都可以帮我解决这个问题吗?我试图解决这些花费 24 小时的问题
【问题讨论】:
标签: json asp.net-mvc serialization kendo-ui kendo-grid