angularjs - Angular Datatable - Filtering or sorting with "Angular Way" deleting rows -
i reduced code smallest version error.
the point is, create table, angular way, empty array table rows.
after that, fetch data, , add same array (with angular.copy)
even though correctly added table itself, if click on column title sort it, or try filter typing in input box, table deletes rows.
could problem $digest or $apply?
i've created codepen reproduce codepen
html
<table datatable="" dt-options="datatable.dtoptions" dt-column-defs="datatable.dtcolumndefs"> <thead> <tr><th></th><th>id</th><th>comuna</th><th>proyecto</th></tr> </thead> <tbody> <tr ng-repeat="doc in json"> <td>a</td> <td>b</td> <td>c</td> <td>d</td> </tr> </tbody> </table>
javascript
$scope.json = []; $scope.load = function(){ _.each(thajson.d.results, function(doc, i) { $scope.json.push(angular.copy(doc)) }) }
you need set datatable attribute "ng" when using angular datatables "angular way"
datatable="ng"
<table datatable="ng" dt-options="datatable.dtoptions" dt-column-defs="datatable.dtcolumndefs"> <thead> <tr> <th></th> <th>id</th> <th>comuna</th> <th>proyecto</th> </tr> </thead> <tbody> <tr ng-repeat="doc in json"> <td>a</td> <td>b</td> <td>c</td> <td>d</td> </tr> </tbody> </table>
Comments
Post a Comment