This is a migrated thread and some comments may be shown as answers.

Send JSON Result from Popup?

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sL342799
Top achievements
Rank 1
sL342799 asked on 24 Sep 2012, 04:01 AM
Hi,

I am using the latest build of Kendo UI (2012.2 913) and I am trying to display a "success" message after a user creates a new record using popup template.

Currently I am returning a JSON Object once the insert is completed as:

 public ActionResult GalleryCreate([DataSourceRequest]
                                          DataSourceRequest request, UserCreateModel model) // decorated with DataSourceRequestAttribute
        {
                if (null != model && ModelState.IsValid)
                {
                    service.CreateUser(model);

                    var json = new
                    {
                        success = true,
                        successMessage ="Successfully added a new User!"
                        
                    };
                    return Json(json);
                }
}

--->

in my razor page, I am binding to the requestEnd function:

    $(document).ready(function () {
        var grid = $("#userGrid").data("kendoGrid").dataSource;
        grid.bind("requestEnd", function (e) {
            if (e.type == "create") {

                alert(e.successMessage);

            }


        });

    });

--> The event is firing, but I am not sure how to get my hands on the JSON object to display a "success message"?

Thanks!

1 Answer, 1 is accepted

Sort by
0
sL342799
Top achievements
Rank 1
answered on 24 Sep 2012, 03:48 PM
So I managed to get it working using the following:

<script type="text/javascript" language="javascript">

    $(document).ready(function () {
        var grid = $("#galleryGrid").data("kendoGrid").dataSource;

        grid.bind("requestEnd", function (e) {



            if (e.type == "create") {

                alert(e.response.successMessage);
            
            }


        });



    });
Tags
Grid
Asked by
sL342799
Top achievements
Rank 1
Answers by
sL342799
Top achievements
Rank 1
Share this question
or