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>