3

web method:

   <WebMethod()>
   Public Shared Function Pcpacking() As IEnumerable(Of Packing)
   Dim db As New STOREEntities
   Return db.PC_PACKING_HISTORIES. _
   Where(Function(q) q.PACK_DATE > "1388/11/07"). _
   Select(Function(q) New Packing _
              With {.Packdate = q.PACK_DATE,
                    .Packserialnumber = q.PACK_SERIAL_NUMBER,
                    .Netweight = q.NET_WEIGHT,
                    .Packusername = q.PACK_USER_NAME}).ToList()
   End Function

script:

$(function () {
       $("#grid").kendoGrid({
           height: 200,
           columns: [
                { field: "Packserialnumber", width: "150px" },
               { field: "Netweight", width: "50px" },
               { field: "Packusername", width: "150px" },
               { field: "Packdate", width: "100px" }
           ],
           editable: false,
           dataSource: {
               schema: {
                   data: "d",
                   model: {
                       id: "Packserialnumber",
                       fields: {
                           Packserialnumber: { editable: false, nullable: true },
                           Netweight: { type: "number", validation: { required: true, min: 1} },
                           Packusername: { validation: { required: true} },
                           Packdate: { validation: { required: true} }
                       }
                   }
               },
               batch: false,
               transport: {
                   read: {
                       url: "Default.aspx/Pcpacking",
                       contentType: "application/json; charset=utf-8",
                       type: "POST"
                   }
               }
           }
       });
   });

with this condition(PACK_DATE > "1388/11/07" 366 records) everything works well.but when i change date to 1388/11/06 1260 records or 1388/11/05 5460 records or ... following error occurs:

{"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. ","StackTrace":" at System.Web.Script.Serialization.JavaScriptSerializer. Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n
at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)", "ExceptionType":"System.InvalidOperationException"}

i think kendo grid dont suppport huge data.Any suggestions?
sorry for my bad english.

Damith
  • 62,401
  • 13
  • 102
  • 153
Meysam Savameri
  • 558
  • 2
  • 12
  • 30
  • Go to this link :) Hopefully solved. http://stackoverflow.com/questions/36192517/how-do-i-bind-very-huge-amount-of-base64-string-in-kendo-grid/36257737#36257737 – Wint Khet Mar 28 '16 at 07:19
  • Go to this link :) http://stackoverflow.com/questions/36192517/how-do-i-bind-very-huge-amount-of-base64-string-in-kendo-grid/36257737#36257737 – Wint Khet Mar 28 '16 at 07:41

2 Answers2

2

The problem is actually that by default, the .NET JSON serializer throws an exception if the resulting JSON string is larger than 100 kB. Obviously, sending thousands of records is larger than the limit. You can change this setting, but I wouldn't recommend it for your application.

Instead, configure the grid to request small chunks of the data at a time. It looks like you can configure Kendo Grid to load more data as you scroll.

$("#grid").kendoGrid({
    dataSource: {
        type: "odata",
        serverPaging: true,
        serverSorting: true,
        pageSize: 100,
        transport: {
            read: {
                url: "Default.aspx/Pcpacking",
                contentType: "application/json; charset=utf-8",
                type: "POST"
            }
        }
    },
    scrollable: {
        virtual: true
    },

    ...
});

Your server-side script will have to handle the top (how many records to send) and skip (where to start) parameters that Kendo sends along.

Community
  • 1
  • 1
josh3736
  • 139,160
  • 33
  • 216
  • 263
-1
$(function () {
       $("#grid").kendoGrid({
           height: 200,
           columns: [
                { field: "Packserialnumber", width: "150px" },
               { field: "Netweight", width: "50px" },
               { field: "Packusername", width: "150px" },
               { field: "Packdate", width: "100px" }
           ],
           editable: false,
           dataSource: {
               schema: {
                   data: "d",
                   model: {
                       id: "Packserialnumber",
                       fields: {
                           Packserialnumber: { editable: false, nullable: true },
                           Netweight: { type: "number", validation: { required: true, min: 1} },
                           Packusername: { validation: { required: true} },
                           Packdate: { validation: { required: true} }
                       }
                   }
               },
               batch: false,
               transport: {
                   read: {
                       url: "Default.aspx/Pcpacking",
                       contentType: "application/json; charset=utf-8",
                       dataType: "json"
                   }
               }
           }
       });
   });
HamidReza
  • 1,726
  • 20
  • 15
  • You should have edited your original answer, instead of reposting it. An explanation of the problem and how it is solved wouold also be helpfull. – Devolus Dec 19 '13 at 07:50