Events on Grid.Editable.Window

2 posts, 0 answers
  1. Tim
    Tim avatar
    4 posts
    Member since:
    Oct 2012

    Posted 06 May 2015 Link to this post

    I am trying to get events to fire on a popup window used for the editor on a grid.  My code is below.  When I review the generated script, the .Window does not get configured with "Open" or "Activate".  Can anyone tell me what I need to do to get these events to fire?

     

    @(Html.Kendo().Grid<FooRecord>()
        .Name("cFooGrid")
                .Columns(c =>
                {
                    c.Bound(f => f.Foo);
                    c.Bound(f => f.Bar);
                    c.Bound(f => f.Bas);
                    c.Command(a => a.Edit());
                })
                .Editable(e => e
                    .Mode(GridEditMode.PopUp)
                    .Window(w => w.Events(v => v.Open("OnEditStart").Activate(@<text>function () {console.log("EditWindow.Activate")}</text>)))
                )
                .ToolBar(t =>
                {
                    t.Create();
                })
                .DataSource(ds => ds
                    .Ajax()
                        .Create(r => r.Action("UpdateIndex", "Home"))
                        .Read(r => r.Action("IndexList", "Home"))
                        .Update(u => u.Action("UpdateIndex", "Home"))
                    .Model( m => {
                        m.Id(f => f.Foo);
                    })
                )
    )
  2. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2622 posts

    Posted 08 May 2015 Link to this post

    Hi Tim,

    In order to attach event handler to the Popup window you should use the Grid edit event. As an example: 
    @(Html.Kendo().Grid<FooRecord>()
        .Name("cFooGrid")
        //....
        .Events(ev=>ev.Edit("onEdit"))
    )
     
    <script>
    function onEdit(e) {
        e.container.data("kendoWindow").bind("activate", function () {
            //Your custom logic
        })
    }
    </script>
    Keep in mind that the "open" event of the window cannot be used as it is already opened when the "edit" event of the grid is triggered.

    Regards,
    Iliana Nikolova
    Telerik
     

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

     
Back to Top