This is a migrated thread and some comments may be shown as answers.

Destroy and recreate grid broken in latest kendo

2 Answers 2459 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 15 Jan 2015, 11:40 PM
We have a UI where we destroy and then recreate a kendoui grid, like:

grid.destroy();
grid.wrapper.empty();


Since going to the latest kendo, we get an error. These two fiddles show it working with 2013.3.1119, and failing with 2014.3.1314 (javascript error in console).

Is there something we're doing wrong, or is this a bug?

This fiddle works (kendoui 2013.3.1119):
http://jsfiddle.net/yosr5xgt/1/

This fiddle is broken (kenodui 2014.3.1314):
http://jsfiddle.net/cLonmd7q/1/

Thanks,
Ryan









2 Answers, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 16 Jan 2015, 12:16 AM
[There doesn't seem to be a way to edit my orig post, so replying here]

Here is another example, closer to our real code. You will again see the first fiddle works. The second fiddle gets a js error when clicking the Recreate Grid button.

It seems like what is happening is the grid.destroy() call is not properly cleaning up the data-bind="visible: showingGrid" on the div id="grid". So, when we later try to set a property that is a dependee of the visible binding, kendo fails when trying to update that visible binding. i.e.  model.set("refreshing", true);

Good 2013.3.1119:
http://jsfiddle.net/befyv2vt/1/

Broken 2014.3.1314:
http://jsfiddle.net/63pa44cp/1/

Thanks again for any guidance,
Ryan
0
Kiril Nikolov
Telerik team
answered on 19 Jan 2015, 11:29 AM

Hello Ryan,

The destroy() method does not remove the MVVM bindings. So in your case you need to unbind and then bind the grid when you recreate it. Here is an example:

http://dojo.telerik.com/@Kiril/aNUne

I would also suggest you to take a look at the setOptions() method that you can use to change options within the grid, without the need of destroying it.

Regards,

Kiril Nikolov

Telerik

 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or