Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<div ng-controller="BasicExampleController" style="width: 100%">
<ng-react-grid grid="grid"></ng-react-grid>
<button type="button" ng-click="toggleVisibleCheckboxes()">Toggle Visible Checkboxes</button>
<button type="button" ng-click="reloadData()">ReloadData</button>
<button type="button" ng-click="edit()" ng-show="!isEditing()">Edit Grid</button>
<button type="button" ng-click="save()" ng-show="isEditing()">Save Grid</button>
<button type="button" ng-click="cancel()" ng-show="isEditing()">Cancel</button>
Expand Down Expand Up @@ -46,6 +47,10 @@
checkboxState = !checkboxState;
checkboxGrid.setVisibleCheckboxState(checkboxState);
};

$scope.reloadData = function() {
$scope.grid.refresh();
};

$scope.edit = function () {
$scope.grid.edit();
Expand Down Expand Up @@ -82,7 +87,7 @@
disableCheckbox: isOddRow(index)
};
});

/*
$scope.grid = {
data: dataSet,
columnDefs: [
Expand All @@ -102,8 +107,8 @@
}
]
};

/*$scope.grid = {
*/
$scope.grid = {
data: [],
columnDefs: [
{
Expand All @@ -117,20 +122,20 @@
],
/*rowClick: function(row) {
console.debug(row);
},
},*/
localMode: false,
getData: function () {
var grid = this;
$timeout(function () {
if (grid.search) {
$scope.grid.data = [];
} else {
$scope.grid.data = dataSet.slice((grid.currentPage - 1) * grid.pageSize, (grid.pageSize * grid.currentPage));
}
$scope.grid.totalCount = dataSet.length;
}, 2000);
if (grid.search) {
$scope.grid.data = [];
} else {
$scope.grid.data = dataSet.slice((grid.currentPage - 1) * grid.pageSize, (grid.pageSize * grid.currentPage));
}
$scope.grid.totalCount = dataSet.length;
}, 2000);
}
};*/
};
});

</script>
Expand Down
14 changes: 6 additions & 8 deletions src/js/classes/ngReactGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,14 @@ NgReactGrid.prototype.setupUpdateEvents = function () {
* Initializes the scope watchers needed for the grid
*/
NgReactGrid.prototype.initWatchers = function () {
this.scope.$watchCollection("grid.data", function (newValue, oldValue) {
if (newValue !== oldValue) {
if (this.isServerMode() && this.react.loading) {
this.scope.$watch("grid.data", function (newValue, oldValue) {
if (this.isServerMode() && this.react.loading) {
this.react.loading = false;
}

this.update(this.events.DATA, {
data: newValue
});
}

this.update(this.events.DATA, {
data: newValue
});
}.bind(this));

this.scope.$watchCollection("grid.columnDefs", function (newValue, oldValue) {
Expand Down