Deckgrid execute only once
So I tried to use Deckgrid for my website and it works when I load the homepage for the first time. Everything looks perfect. But when I click on a article and go back to the homepage it seems like deckgrid doen't execute again. Is there a way to execute deckgrid each time not only once?
@gielcobben Thanks for reporting. Can you please post a link to your website so that I can take a look?
Hi, I had the same issue today. After route change (using the same view), if deckgrid detects the old model and new model are the same, it will decide to not build columns. Resulting in an empty page.
if (!angular.equals(oldModel, newModel)) {
self.$$createColumns();
}
In my case, this happens when we give cards array a new value from memory cache:
this.cards = [];
this.cards = oldvalue; //load from cache
deckgrid won't able to catch this change. An workaround would be adding $timeout to the second assignment.
So I have a similar issue. I have two views both use deckgrid. And each view has its own controller and retrieves own data. The problem is when switching between the views (ng-show/ng-hide) one of the view always shows empty grid.
It seems that this is the pattern:
Refresh the page with view1, toggle to view2, toggle back to view1 and view1 is empty.
If I flip the order of view1 and view2, then view2 is the problem.
Thanks for looking into this.
I think I have a related (maybe?) problem using ui-router and deckgrid.
I sometimes get 'Uncaught TypeError: Cannot read property 'columns' of undefined' when resizing a window after changing views.
Deckgrid.prototype.$$onMediaQueryChange = function $$onMediaQueryChange () {
var self = this,
layout = this.$$getLayout(); // <-- It seems this here can return undefined. Which probably is obvious since the grid element does no longer exist after changing view.
Sure not a big problem since the grid works as expected, but if I keep jumping between views, it seems as if each time I enter a view with a grid a new "listener" is attached and soon I get 10+ errors every time I resize ( the amount of errors increase with view changes) .
Without knowing anything about how this works behind the curtains, I assume that what we need is some way to "unregister" a grid before changing view. (Perhaps there is a way already?).
I am having this same problem with the latest version of ui-router. It seems like the deckgrid directive isn't properly destroying and reinitializing on state changes. This is a showstopper change.
I found a temporary fix:
You can force deckgrid to reinitialize by wrapping your directive call in an ng-if and toggling that scope variable between true and false. See example here:
-- In my HTML --
<div deckgrid source="gridItems" ng-if="showGrid"></div>
-- In my controller --
$scope.$on('$destroy', destroy);
function destroy() {
$scope.gridItems = [];
$scope.showGrid = false;
}
-- later in my function that gets the gridItems array --
$scope.showGrid = true;
It's not ideal, but it patches the problem for me for the time being.
I have the same issues in using deckgrid and ui-router I think this problem was caused by the destroy event. deckgrid would trigger destroy event if we change route from viewA to viewB which have a deckgrid each other. We hope clean the unused watches in viewA, but in fact the watches in viewB have been cleaned. so there is nothing happened when we changed datasource of deckgrid in viewB. I check the source code and debug. I found that deckgrid is designed as a singleton, when deckgrid in viewB has been created, it override the destroy event which bind on viewA. I solve this problem by a temporary way that comment the destroy event listen code. @akoenig Hope owner could fix this problem, thanks.