Here is the example of the ng-Grid with infinite scroll using "ngGridEventScroll" events. supports group by filter and sort.
Example: http://plnkr.co/edit/AY68jf?p=preview
// main.js
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.currentDataPosition = 1;
$scope.lastScrollPosition = 0;
$scope.mySelections = [];
$scope.myData = [{EmployeeName:"David", Emailaddress:"[email protected]", Technology:"MVC"},
{EmployeeName:"Christina", Emailaddress:"[email protected]", Technology:"MVC"},
{EmployeeName:"Peter", Emailaddress:"[email protected]", Technology:".Net"},
{EmployeeName:"Jhon", Emailaddress:"[email protected]", Technology:"SP"},
{EmployeeName:"Michel", Emailaddress:"[email protected]", Technology:"SP"},
{EmployeeName:"Mark", Emailaddress:"[email protected]", Technology:"MVC"},
{EmployeeName:"Reobert",Emailaddress:"[email protected]",Technology:".Net"}
];
$scope.gridOptions =
{
data: 'myData',
columnDefs: [
{field:'EmployeeName', displayName:'Employee Name' ,width:'150px'},
{field:'Emailaddress', displayName:'Email Address',width:'200px'},
{field:'Technology', displayName:'Technology',width:'100px'}
],
groups :['Technology'],
groupsCollapsedByDefault: false,
showSelectionCheckbox: true,
selectWithCheckboxOnly: false,
selectedItems: $scope.mySelections,
//multiSelect: true,
//filterOptions: {filterText: '', useExternalFilter: false},
//showColumnMenu: true,
//showFilter: true,
};
$scope.GetMoreData = function(position)
{
if(typeof(position) == 'undefined')
{
position = 0;
}
for (var i = 1 ; i < 31 ; i++)
{
var dep = "MVC";
if(i % 3 == 0)
{
dep = "Consult";
}
else if (i % 5 == 0)
{
dep = "Audit";
}
else if (i % 7 == 0)
{
dep = "Audit";
}
else if (i % 4 == 0)
{
dep = ".Net";
}
var vPos = '('+position+')-' + i;
var name = "Employee"+vPos;
var email = name + "@abccompany.com";
var employee = {EmployeeName:name,Emailaddress: email,Technology:dep}
$scope.myData.push(employee);
}
}
$scope.$on('ngGridEventScroll', function ()
{
var ngGridView = $scope.gridOptions.ngGrid.$viewport[0];
var scrollTop = ngGridView.scrollTop;
var scrollOffsetHeight = ngGridView.offsetHeight;
var currentScroll = scrollTop + scrollOffsetHeight;
var scrollHeight = ngGridView.scrollHeight;
console.log(scrollTop);
console.log(scrollHeight);
$scope.currentDataPosition++;
$scope.isLoading = true;
$scope.GetMoreData($scope.currentDataPosition);
$scope.isLoading = false;
console.log('Scrolled .. ');
});
$scope.GetMoreData(1);
});
ngViewport
. – Gosport