我一直在研究这个问题很长一段时间了。 基本上,我使用Kendo Grid来将数据从控制器显示到ViewPage。将数据绑定到KendoGrid时MVC中的MaxJsonLength错误
但是,当我运行的观点,我不断收到此错误 maxJsonLengthError
我如何纠正这个问题?提前感谢所有帮助。 请参阅我的编辑
这里是我的ControllerCode: -
public ActionResult Index()
{
ViewData["DealsList"] = objDealerModel.listDeals;
return View();
}
这里是我的ViewPage代码: -
@(Html.Kendo().Grid((IEnumerable<WCB.Models.DealerQueue>)ViewData["DealsList"])
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.DealId).Visible(false);
columns.Bound(p => p.DealRefNo).Title("Deal No");
columns.Bound(p => p.CustomerName).Title("Customer Name");
columns.Bound(p => p.DealType).Title("Deal Type");
columns.Bound(p => p.Location).Visible(false);
columns.Bound(p => p.CreatedDate).Title("Created Date");
columns.Bound(p => p.Currency).Title("Currency");
columns.Bound(p => p.Amount).Title("FCY Amount");
columns.Bound(p => p.DealValue).Title("Deal Amount").ClientTemplate("#= kendo.toString(DealValue, 'n') #");
columns.Bound(p => p.Status);
columns.Command(command => command.Custom("ViewDetails").Click("ViewDealDetails")).Title("View");
})
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(20))
.Sortable()
.Scrollable(scr => scr.Height("auto"))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
)
)
编辑: 我尝试使用myController中的这段代码: -
var jsonResult = Json(objDealerModel.listDeals, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
任何人都可以基于此建议需要在我的viewPage中为KENDO GRID进行哪些更改?不太熟悉的剑道
只是哈瓦看看[**这**](http://stackoverflow.com/a/7207539/3814721) – mmushtaq
参见[这个答案](http://stackoverflow.com/questions/ 5692836/maxjsonlength-异常在-ASP净MVC-期间-javascriptserializer)。但基本上你太多的数据发送到视图(没有人将能够吸收大量信息 –
@StephenMuecke,尝试使用 VAR jsonResult = JSON(objDealerModel.listDeals,JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return jsonResult; 任何想法如何我的viewPage应该改变基于这个?? – reizonShrestha