-
Notifications
You must be signed in to change notification settings - Fork 490
How to change DOM after the datatable is rendered correctly? #262
Comments
Mmh. It's weird. I'll look into this. |
l-lin, thanks for your reply. |
Indeed... Not sure why... |
Same case here, I think something happends when the collection is updated, is in that moment when the table disappears. But it only disappears after vm.dtOptions is modified. |
I think I found what the problem is, and I have a possible (temporary) solution. When the dataTable options are modified (like vm.dtOptions, in the example) and after update the collection, angular takes that a action (the collection update) as if the collection actually would be updated twice (I don't know why), and the method '_destroyAndCompile' is called twice, because of the listener:
_parentScope.$watchCollection(_ngRepeatAttr, function(){...});
So, Inside of this listener the method
is executed, and in the second time, the sentences
In this plnkr you can realize that when the "Reload data" button is clicked (at the first time, before the "Change options" button) the table is destroyed only once, and after you clicked the "Change options" button and "Reload data" button the table is destroyed twice, and that's the problem (see the javascript console). My solution: Uncomment the condition Hope it helps and I apologize for my bad english. |
@zafra6 |
@giankotarola I added the var _newValue in the method create(options). |
@zafra6 |
Please help i need something like this i think. I have a json for languages and if i rerender datatables translate ok but Is there a way of translate captions tools witout rerender any other method? |
solve "blank page after reload in angular way" issue Ref: l-lin#262 (comment)
In version 'angular-datatables - v0.5.2' solved the problem in line 904-916 staying that way: function _destroyAndCompile() { // Re-compile because we lost the angular binding to the existing data |
vinodf fix works great for me to address this same issue -- I suggest this get rolled into master -- will do a fork/pull request on this soon |
+1 for this fix! I just spent a couple of days trying to debug why this was happening :-) |
I would like to change DOM after the datatable is rendered. For example, if the data length is less than some number, the pagination control will be hidden.
But when I change DOM by this:
the table will crash when I add/remove item to/from the table?
I have made a plnkr example based on the demo "Changing data with the Angular way": http://plnkr.co/edit/EfNUyEg00iMfhlARwYYV
Somehow I cannot see any error message in the plnkr example. But I can see error messages in my own project (I am not sure are these messages helpful):
The text was updated successfully, but these errors were encountered: