3

So, im trying to pass data to the controller action and it keeps getting there as empty even though when debugging in the data is populated before the call. Im really not sure what I'm doing wrong. I've tried make it a post instead of a get, ive tried not using url.action and just putting in the fully qualified path.

Here is the code from the view.

function openWindow() {
        var grid = $("#AjaxGrid").data("kendoGrid");
        var selectedData = grid.dataItem(grid.select());
        var stringData = JSON.stringify(selectedData);

        var window = $("#UserDetailDiv").data("kendoWindow");
        var PopUpTitle = "User Detail: ";

        window.setOptions({
            title: PopUpTitle,
            content: "Loading....."
        });

        window.refresh({
            url: "@Url.Action("UserDetail", "Inquiry")",
            data: {
                userString: stringData,
                directCall: "T"
            },
            error: function (xhr, textStatus, exceptionThrown) {
                window.close();
                alert($.parseJSON(xhr.responseText));
            }
        });
        window.open();
        window.center();
    }

Here is the signature of the action.

    <ViewModelActionFilter> _
    Public Function UserDetail(userString As String, directCall As String) _
4
  • 1
    How is your stringData looks like ? Did you try serialize instead of stringify ? I am not seeing GET or POST in your code Commented Mar 18, 2015 at 16:19
  • telerik told me it always sends as a get. Also, i am deserializing in the method. Commented Mar 19, 2015 at 13:24
  • Try passing data like this data = form.serialize() + '&' + $.param(directCall); and in window,refresh data: data Commented Mar 19, 2015 at 14:36
  • The issue there is the data is coming from a selected grid row. Commented Mar 19, 2015 at 15:17

1 Answer 1

4

I got it working with a post. The issue is when using the kendo window and setting iFrame:true, it blocks the post. I removed it and now it is working great. Before:

@(Html.Kendo().Window().Name("UserDetailDiv") _
.Title("User Details") _
.Visible(False) _
.Modal(True) _
.Height(500) _
.Draggable(True) _
.Width(900) _
.iframe(true)

)

After:

@(Html.Kendo().Window().Name("UserDetailDiv") _
.Title("User Details") _
.Visible(False) _
.Modal(True) _
.Height(500) _
.Draggable(True) _
.Width(900)

)

Refresh code:

        function openDetailWindow() {
        var grid = $("#AjaxGrid").data("kendoGrid");
        var selectedData = grid.dataItem(grid.select());
        var stringData = JSON.stringify(selectedData);

        var window = $("#UserDetailDiv").data("kendoWindow");
        var PopUpTitle = "User Detail: ";

        window.setOptions({
            title: PopUpTitle,
            content: "Loading....."
        });

        window.refresh({
        url: "../Inquiry/UserDetail",
        type: "POST",
        data: { userData: stringData, directCall: "T" }
        });
        window.open();
        window.center();
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.