[英]Not able to pass more than 1000 records to kendo gridview
I am using Kendo Gridview to display some records. 我正在使用Kendo Gridview显示一些记录。 These records are in Json when retrieved from the database and stored in a list of the same class.
从数据库中检索这些记录并将其存储在同一类的列表中时,这些记录在Json中。 I have no problem when the list is of count 1000, but any number above 1000 triggers an exception : "
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
当列表的数量为1000时,我没有问题,但是大于1000的任何数量都会触发异常:“ 使用JSON JavaScriptSerializer进行序列化或反序列化时出错 。字符串的长度超过了在maxJsonLength属性上设置的值。 ”
I have tried changing the maxJsonLength value in web.config and in appsettings as recommended in some of the solutions I found on stack overflow. 我曾尝试根据我在堆栈溢出时发现的一些解决方案中的建议,更改web.config和appsettings中的maxJsonLength值。 But none of them work.
但是它们都不起作用。 This is my view:
这是我的看法:
@(Html.Kendo().Grid(Model)
.Name("grid")
.Scrollable()
.Filterable()
.Columns(columns =>
{
//Columns added here
})
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Pageable(pageable => pageable
.Refresh(false)
.PageSizes(true)
.ButtonCount(3))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
})
.Read(read => read.Action("Action", "Controller"))
.PageSize(50)
)
.Events(e => e.DataBound("selectDefault"))
I came to realize that the Json Lists that I was passing to the view had too many complex data types(ie class objects and enums) and that was the reason none of the solutions worked. 我意识到,我传递给视图的Json列表具有太多复杂的数据类型(即类对象和枚举),这就是所有解决方案都不起作用的原因。 So I referred to a solution described in this link and created an intermediate view model.
因此,我引用了此链接中描述的解决方案,并创建了一个中间视图模型。 In this model I added all the necessary attributes that I wanted and passed it to view.
在此模型中,我添加了所需的所有必要属性,并将其传递给视图。 It works really fine now
现在真的很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.