Here code
Creating edit button on every row.
var statusTemplate = '<button type="button" class="btn btn-default" ng-click="grid.appScope.add(lg,{{row.entity.StudentID}})">Add</button> '; /** <div> {{row.entity.StudentID}}</div>**/
$scope.studentModel = {
paginationPageSizes: [10, 20, 75],
paginationPageSize: 10,
useExternalPagination: true,
useExternalSorting: true,
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
enableVerticalScrollbar: uiGridConstants.scrollbars.NEVER,
columnDefs: [
{ field: 'StudentID', displayName: 'No.' },
{ field: 'StudentName', displayName: 'Name' },
{ field: 'Height', displayName: 'Height' },
{
field: 'StudentID',
displayName: 'status',
cellTemplate: statusTemplate
}
],
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
$scope.gridApi.core.on.sortChanged($scope, function (grid, sortColumns) {
if (sortColumns.length == 0) {
paginationOptions.sort = null;
paginationOptions.sortBy = 'StudentID';
} else {
paginationOptions.sort = sortColumns[0].sort.direction;
paginationOptions.sortBy = sortColumns[0].field;
}
$scope.getAllUser();
});
gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
paginationOptions.pageNumber = newPage;
paginationOptions.pageSize = pageSize;
$scope.getAllUser();
});
}
};
$scope.add = function (size, id) {
console.log(id);
});
I have 3 page in the grid.
On first page, ng-click="grid.appScope.add(lg,{{row.entity.StudentID}})
binding (rendering) perfect and click on button then got correct id on console result.
But When I go on second page then rendering StudentID perfect (Using F12). But When I click on any button on second page then it give me first page studentID.
grid.appScope is working only first Page. It is not working on other pages (rendering perfect but on click give wrong id).
How to solve this issue?