Serializing grid data to json string

2 posts, 0 answers
  1. Shabtai
    Shabtai avatar
    38 posts
    Member since:
    Nov 2012

    Posted 25 Jun 2013 Link to this post

    Hi,

    I'm trying to implement grid serialization example:
    http://stackoverflow.com/questions/10324565/how-to-get-the-displayed-data-of-kendogrid-in-json-format

    $.ajax({
        type: 'post',
        data: kendo.stringify($("#Grid").data("kendoGrid").dataSource.view()),
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        url: '@Url.Action("CreateExcelFile","Helper")',
        success: function (response) {
        },
        error: function (request, status, errorThrown) {
        }
    });
    On server side I get, Request.Form.Count = 0...

    Any help would be appreciated...

    Thanks
    Shabtai

  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 27 Jun 2013 Link to this post

    Hello Shabtai,

    The form data will be empty since you are posting the data as JSON. You should use the model binder to get the items on the server:

    public ActionResult Action(IEnumerable<MyModel> models)
    {

    You should also use the toJSON method to convert the view to an array of plain JavaScript objects. Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top