Double click only works once after ajax call

1 Answer 411 Views
Grid Window
Prabhat
Top achievements
Rank 1
Prabhat asked on 09 Dec 2021, 05:12 PM

I'm trying to implement a double click event on kendo grid row which would open a kendo window and the content is called making an ajax call based on the row data. The content gets it's data from a view. It works for the first time but when I close the window using out-of-the box window close button and select the same row or another row, the double click doesn't work. I want client to have option to get out of window/form and switch the row and double click it.  Developer Tools shows the following error when dblclick is attempted second time or on subsequent attempts. ""dataitem" uncaught typeerror cannot read property of undefined (reading 'dataitem') at HTMLTableRowElement.

"Below is a code snippet. 

//grid

@(Html.Kendo().Grid(Model)

        .Name("mygrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.id).Title("id");            
            columns.Bound(p => p.Col2).Title("Col2").Width(130);

        })
        .Pageable()
        .Sortable()
        .Scrollable(scr => scr.Height(430))
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(20)
            .ServerOperation(false)
         )
        .Selectable()
)

     @{
    string[] actions = new string[] { "Close" };

}
<div class="windowdiv">
        <kendo-window name="window"
                      draggable="true"
                      resizable="true"
                      width="700"
                      height="650"
                      min-height="600"
                      min-width="600"
                      modal="true"
                      position-top="0%"
                      position-left="30%"
                      actions="actions">
            <content>
            </content>
            <popup-animation enabled="false" />
        </kendo-window>
    </div>
<script>
    $(document).ready(function () {
        /*$("#window").data("kendoWindow").center();*/
        $("#window").data("kendoWindow").close();
    });
    
    //double click
    $("#mygrid").on("dblclick", "tr.k-state-selected", function () {
        var dataItem = $("#mygrid").data("kendoGrid").dataItem($(this));
        id = (dataItem.id);
        alert("double clicked");

        $("#window").data("kendoWindow").title("Id: " + id);
        $("#window").kendoWindow({
            content: {
                url: "@Url.Action("ActionName","ControllerName")",
                data: { id: id }
            }
        });
        /*$("#window").data("kendoWindow").center();*/
        $("#window").data("kendoWindow").open();     
    });
</script>

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 14 Dec 2021, 11:18 AM

Hi, 

Based on the provided information, I created a sample project with the window and dblclick handler. However, it appears that I could not replicate the reported behavior.

Is it possible for you to modify the sample attached to my response, replicate the error and send it back to me? 

 

Kind regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid Window
Asked by
Prabhat
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or