Our application is a single page application (SPA) and has a number of grids. Some of these grids are loaded with data as soon as you go to the page, using the dataSource option. This works great except, if I navigate away from a page (which involves removing the HTML for that page, and thus the HTML for the grid from the current page and injectiong the HTML of a new page) before the grid has been populated, then the callback to populate the grid throws an exception. The call stack is:
_inferOpType [infragistics.ui.grid.framework.js] Line 28 Anonymous Function [jquery-ui.js] Line 401 _renderData [infragistics.ui.grid.framework.js] Line 26 Anonymous Function [jquery-ui.js] Line 401 proxy [jquery-1.9.1.js] Line 818 _completeCallback [infragistics.datasource.js] Line 35 fire [jquery-1.9.1.js] Line 1037 fireWith [jquery-1.9.1.js] Line 1148 done [jquery-1.9.1.js] Line 8089 callback [jquery-1.9.1.js] Line 8598
Is there any way I can prevent this? I mean, I could load the data using an ajax call and then verify the grid's still there before trying to assign the data, but I just wanted to see if maybe there way some way I could either prevent or quietly dispose of this exception...
Hi Pete,
which code do you call when you navigate away from a page? Do you destroy the grid?
$("#grid1").igGrid("destroy");
I guess something is not cleaning up.
Hope it helps. Thanks,
Angel
I wasn't doing anything. Iv'e added a call to
$("#grid").igGrid("destroy");
I verified it's getting called when navigating away from the page, but the callback is still throwing an exception.
Bhadresh,
My apologies. This issue is solved, as far as I can tell. I wasn't calling destroy. I've run into it once or twice since I made the changes, but there may be a page or two out there that I don't have it fixed on. But given that adding the destroy call got rid of about 95% of the occurences, I'm going to call that a solution and I'll try to track down what's going on in these other couple of grids that are giving me that error.
I am putting together a sample to look into this behavior. In order to look into this provide me with the grid initialization code that will help me to understand how grid is configured; if you are using igloader.
Here's how our SPA works: You navigate to a page and there's a javascript object associated with each page. Each JS page object has an init() method and a destroy() method. When you navigate to a page, the init() method gets called and the grid is created. In the destroy() method for the page, I'm now calling the igGrid('destroy') for the grid. But still, if I navigate away from the page before the callback completes and the grid populates, it's throwing an exception.
So I'm assuming, based on your previous post, that if you call destroy on the grid prior to the datasource callback, there shouldn'' be an error?