I have a bunch of Kendo grids within divs. I am letting the user sort those divs on the screen. After sorting, my Kendo grid no longer functions correctly, for example, clicking on a column header no longer sorts. I'm sure it has to do with me removing and replacing the element elsewhere on the screen. How do I rebind the grid after the element has been removed from the DOM and replaced. This is the relevant line of JQuery where the kendo grids are, among other html, contained within sortedRows.
let myGrid = $("myGrid").data("kendoGrid");
let sortedRows = [...rows];
if (direction !== "original") {
sortedRows.sort(function (a, b) {
let rowA = a.getElementsByClassName("responsive-table__cell")[columnIndex];
rowA = $(rowA).find(".js-sort-value").text().toLowerCase();
let rowB = b.getElementsByClassName("responsive-table__cell")[columnIndex];
rowB = $(rowB).find(".js-sort-value").text().toLowerCase();
if (sortType === "number") {
rowA = parseFloat(rowA);
rowB = parseFloat(rowB);
}
if (direction === "asc") {
return rowA > rowB ? 1 : -1;
} else {
return rowA > rowB ? -1 : 1;
}
});
}
$(`#myCodeBlock`).find(".responsive-table__body").empty().append(sortedRows);