Redirect to strongly typed view based on grid selection

3 posts, 0 answers
  1. Andrew
    Andrew avatar
    2 posts
    Member since:
    Apr 2015

    Posted 20 Apr 2015 Link to this post

    When a user selects a row in my grid, I can get the dataItem from a button click as follows:

    $("#viewApplicationBtn").on("click", function () {
            var grid = $("#Grid").data("kendoGrid");
            var gridData = grid.dataItem(;


    What I would like to do from this point is post this back to my controller, let the MVC model binder map to my ViewModel, and then redirect to another view which is of that model type.

    The roadblock I'm facing is that an ajax post won't accomplish this and I can't pass the properties in a Url.Action helper because there are too many

    here is my ajax:

                type: "POST",
                url: "@Url.Action("ValidateModel")",
                datatype: "json",
                contentType: "application/json",
                data: JSON.stringify(gridData),
                success: function(data) {
                    window.location.href = @Url.Action("Details", "GridController");
                error: function(data) {
                    console.log("post failed");



    So how can I use my grid selection to post to another view with a Model?

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 23 Apr 2015 Link to this post

    Hi Andrew,

    We are not sure what you mean by "ajax post won't accomplish this". What happens when the $.ajax executes? Does it hit the ValidateModel action? Is the parameter of the ValidateModel action properly populated?

    Providing some sample code would allow us to give more suggestions.

    Atanas Korchev

    See What's Next in App Development. Register for TelerikNEXT.

  3. Andrew
    Andrew avatar
    2 posts
    Member since:
    Apr 2015

    Posted 23 Apr 2015 in reply to Atanas Korchev Link to this post

    What I mean is that because it's an ajax post and not a "regular" form post, my MVC method for showing the grant Details view does not redirect the browser on it's return statement:

    public ViewResult Details(string grantId)
        //Query the record based on the id
        var grantApp = _grantFormService.SelectGrantById(grantId);
        //Pass that model to the details view
        return View(grantApp ?? new GrantFormDTO());

    I have since gone a different route and wrapped the grid in a Html.BeginForm and simply passed the row id back to my controller so that I can query the model from the database again and pass it to my Details view.

Back to Top