Reputation: 5924
I have a KendoUI grid. In it, one of the columns has a custom command defined:
command: { text: "Add", click: addLine }
This grid is displayed inside a Kendo window when a user clicks a button. That same button rerenders the grid and clears the HTML first:
$("#kendoGridQuick").html("");
$("#kendoGridQuick").kendoGrid({
After the grid gets created the window shows. My problem is that this command is fired exactly however many times I've shown this window and created the grid. So it works fine the first time through, but gets called twice the second time, and three times the third time, etc.
Upvotes: 0
Views: 3171
Reputation: 1
This is the kendo grid. However, we can handle the below to clear grid before bidding data again.
$("#gridSaleEvent").html("");
Upvotes: -1
Reputation: 40887
The problem is that you are not destroying the Grid
object. You should invoke Grid.destroy
method before clearing the HTML.
var grid = $("#kendoGridQuick").data("kendoGrid");
// detach events
grid.destroy();
In addition, try to save CPU and memory closing and opening but not destroying the grid. As far as you are always using the same basic structure you can re-bind / re-read new data when the window is about to open (much faster and simpler).
Upvotes: 5
Reputation: 20193
Instead of wasting CPU creating and destroying the Grid. Initialize the Grid only once when the page is loaded and just show/hide the window when the button is clicked (you do not need to re-initialize it).
If you still face difficulties share some code so we can see where and how you initialize the Grid.
Upvotes: 2