Sending Multiple Models to the Grid via ActionResult

2 posts, 0 answers
  1. D_R
    D_R avatar
    1 posts
    Member since:
    Feb 2013

    Posted 22 May 2013 Link to this post

    When Adding a model to my grid via a controller action, it is possible that there may be more than one model created as a result of the process.

    Normally, when only one item is added, we are sending the created or updated Model back to the View by calling:            
    return this.Json((new Model[] { singleModelRecord }).ToDataSourceResult(request, this.ModelState));
    Where "singleModelRecord" is a single model.

    However, in this case, I would like to be able to send a List of Models back to the client, and have all the rows added to the grid, instead of having just one of them added, and needing to refresh the grid to see the rest.  This is what I was trying, but only one new model was being shown in the grid:

    return this.Json(arrayOfModels.ToDataSourceResult(request, this.ModelState));
    where "arrayOfModels" is the array of Models that have just been created.

    Is this functionality supported?
  2. Vladimir Iliev
    Vladimir Iliev avatar
    2194 posts

    Posted 24 May 2013 Link to this post

    Hi Daniel,

    Basically this functionality currently is not supported out-of-the-box, however you can use the RequestEnd event of the DataSource to check if current type is "create" to refresh the Grid using the read method

    Kind Regards,
    Vladimir Iliev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top