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

destroying grid does not completely destroy it, apparently

6 Answers 646 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 28 Jun 2013, 04:39 PM
Sorry if this question formats oddly. I'm using Firefox at the moment and wordwrap isn't working correctly here on the forum with FF v22.0.

My application has to do multiple searches against a large database, one search after the other, every few minutes, all day long.

Users click a map, the app gets the latitude and longitude of the location, and then queries the database for entities within a given radius.
The entities are displayed in the grid. Lather. Rinse. Repeat.

I destroy the grid before each search and delay the search for a fraction of a second (I've tried as long as 1.5 seconds) to give the "destruction" time in which to complete.

On the second and subsequent searches, the grid loses its groupable feature.  The grouping-is-not-allowed icon when the user tries to drag the column-header to the group-panel.

It may be relevant that the grid is on a panelBar.

function doSearch() {

    var existingGrid = $('#grid').data('kendoGrid');
    if (existingGrid) {
        existingGrid.destroy();
        existingGrid.wrapper.html("");
    }

    setTimeout(function () {
        FetchData();       // the success handler for this AJAX call instantiates and configures the grid
    }, 222);

}

6 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Jul 2013, 11:38 AM
Hi Tim,

The following demo seems to work as expected. Please check it and let me know if I am missing something.

http://jsfiddle.net/dimodi/Fx5kU/

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tim R
Top achievements
Rank 1
answered on 02 Jul 2013, 11:55 AM
Not sure, since you are not testing the same scenario.  You're recreating the grid with an identical dataset, whereas I'm recreating the grid with a different dataset having the same column structure.   And I am also explicitly specifying aggregates for fields with a footerTemplate and a groupFooterTemplate.


0
Tim R
Top achievements
Rank 1
answered on 02 Jul 2013, 11:58 AM
I posted a question yesterday with further information on this ssue.  I can fix the groupable issue when using 2013Q1 but a phantom column header appears.
0
Tim R
Top achievements
Rank 1
answered on 02 Jul 2013, 12:11 PM
When I also include grid.wrapper.empty() this problem goes away. It seems to bes working now.  IE10 is a little choppy compared to other browsers when dragging to group, and there's a noticeable lag when sorting, but otherwise OK.
0
Rajesh
Top achievements
Rank 1
answered on 17 Apr 2021, 06:32 PM

Hai Tim,

 

I can't open your example can you help me,

I have similar scenario, I want destroy existing grid  and recreate grid.  

Thanks In Advance.

0
Dimo
Telerik team
answered on 19 Apr 2021, 08:10 AM

Hello Rajesh,

I recommend the following documentation article about widget destroy:

https://docs.telerik.com/kendo-ui/intro/widget-basics/destroy

Basically, first you need to execute the destroy() method of the Grid, and then empty or remove its DOM element (<div>).

If you remove the Grid <div>, then you can append a new <div> to the page and create a new Grid instance.

If you empty the Grid <div>, then you can reuse this <div> for a new Grid instance.

Do you have a specific issue with this? Please describe in more details, so that we can help.

Regards,
Dimo
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
Asked by
Tim R
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Tim R
Top achievements
Rank 1
Rajesh
Top achievements
Rank 1
Share this question
or