Datatable is not reflecting $scope updates if the table is configured in a controller via webix-ui=“datatable_config”. Bindings does work fine if the table is configured in html only. What I’m missing?
Pressing Add Row - button does add a row at first time, but consecutive clicks does nothing:
<!doctype html>
<html lang="en" ng-app="webixApp">
<head>
<meta charset="utf-8">
<title>Webix - Angular : Grid</title>
<script src="vendor/js/angular.min.js"></script>
<link rel="stylesheet" type="text/css" href="vendor/webix/codebase/webix.css">
<script type="text/javascript" src="vendor/webix/codebase/webix.js"></script>
</head>
<body ng-controller="webixTestController">
<div style="width:750px;">
<div webix-ui="datatable_config">
</div>
</div>
<br>
<button ng-click="addRecord()">Add Row</button>
<script>
var app = angular.module('webixApp', [ "webix" ]);
app.controller("webixTestController", function($scope){
$scope.records = [
{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rating:9.2, rank:1},
{ id:2, title:"The Godfather", year:1972, votes:511495, rating:9.2, rank:2},
{ id:3, title:"The Godfather: Part II", year:1974, votes:319352, rating:9.0, rank:3},
{ id:4, title:"The Good, the Bad and the Ugly", year:1966, votes:213030, rating:8.9, rank:4},
{ id:5, title:"My Fair Lady", year:1964, votes:533848, rating:8.9, rank:5},
{ id:6, title:"12 Angry Men", year:1957, votes:164558, rating:8.9, rank:6}
];
$scope.datatable_config = {
view: "datatable",
autoheight: true,
select: "row",
data: $scope.records,
columns:[
{ id:"rating", header: "Rating"},
{ id:"year", header: "Year"},
{ id:"votes", header: "Votes"},
{ id:"title", header: "Title"},
]
};
$scope.addRecord = function(){
$scope.records.push({
title:"New Record",
rating:999,
votes:0,
year:2013
});
};
});
</script>
</body>
</html>
Consecutive clicks works fine if the table is configured in html:
<!doctype html>
Webix - Angular : Grid
<script src="vendor/js/angular.min.js"></script>
<link rel="stylesheet" type="text/css" href="vendor/webix/codebase/webix.css">
<script type="text/javascript" src="vendor/webix/codebase/webix.js"></script>
</head>
<body ng-controller="webixTestController">
<div style="width:750px;">
<div webix-ui view="datatable" webix-data="records" autoheight="true" select="row">
<div view="column" id="rating">Rating</div>
<div view="column" id="year">Year</div>
<div view="column" id="votes">Votes</div>
<div view="column" id="title">Title</div>
</div>
</div>
<br>
<button ng-click="addRecord()">Add Row</button>
<script>
var app = angular.module('webixApp', [ "webix" ]);
app.controller("webixTestController", function($scope){
$scope.records = [
{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rating:9.2, rank:1},
{ id:2, title:"The Godfather", year:1972, votes:511495, rating:9.2, rank:2},
{ id:3, title:"The Godfather: Part II", year:1974, votes:319352, rating:9.0, rank:3},
{ id:4, title:"The Good, the Bad and the Ugly", year:1966, votes:213030, rating:8.9, rank:4},
{ id:5, title:"My Fair Lady", year:1964, votes:533848, rating:8.9, rank:5},
{ id:6, title:"12 Angry Men", year:1957, votes:164558, rating:8.9, rank:6}
];
$scope.addRecord = function(){
$scope.records.push({
title:"New Record",
rating:999,
votes:0,
year:2013
});
};
});
</script>
</body>
</html>