Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total Items in footer issue #332

Closed
richtmat opened this issue Apr 12, 2013 · 13 comments
Closed

Total Items in footer issue #332

richtmat opened this issue Apr 12, 2013 · 13 comments
Assignees
Milestone

Comments

@richtmat
Copy link

Total Items in the footer does not show the $scope.pagingOptions.totalServerItems I configured.
Instead, it reads from grid.config.totalServerItems.

@orneryd
Copy link
Contributor

orneryd commented Apr 12, 2013

we switched out the place where totalServerItems is set because people
wanted to update it manually while watching the pagingOptions configuration
variable for changes (so they know when to retrieve more data from the
server).

On Fri, Apr 12, 2013 at 6:44 AM, richtmat notifications@github.com wrote:

Total Items in the footer does not show the
$scope.pagingOptions.totalServerItems I configured.
Instead, it reads from grid.config.totalServerItems.


Reply to this email directly or view it on GitHubhttps://github.com//issues/332
.

-Tim Sweet

@richtmat
Copy link
Author

OK now I set $scope.gridOptions.totalServerItems statically and if totalServerItems > pageSize I can see that value.

But if I use a $http call to get the items from the server totalServerItems is not set (maybe because of async?). Also the maxRows() function from ngFooter Controller is called only once. How do I trigger another call?

@orneryd
Copy link
Contributor

orneryd commented Apr 15, 2013

are you using the $http or $timeout services? because it should just be a
digest once the values have been updated. if you are going an ajax call
then you are outside of the angular context and you may have to manually
trigger a $digest. The $http/$timeout service automatically triggers a
$digest after the promise is resolved.

On Mon, Apr 15, 2013 at 3:05 AM, richtmat notifications@github.com wrote:

OK now I set $scope.gridOptions.totalServerItems statically and if
totalServerItems > pageSize I can see that value.

But if I use a $http call to get the items from the server
totalServerItems is not set (maybe because of async?). Also the maxRows()
function from ngFooter Controller is called only once. How do I trigger
another call?


Reply to this email directly or view it on GitHubhttps://github.com//issues/332#issuecomment-16376587
.

-Tim Sweet

@richtmat
Copy link
Author

yes, I am using $http, encapsulated in a angular service at the first line of my controller.
I don't think its a problem with $digest, because once all js is loaded for ng-grid, the footers maxRows is evaluated. That happens before the promise is resolved.
I guess the databinding is not a two-way binding here because the model in the footer is a function. So when the promise finally is resolved nothing happens any more.
Is there a way to trigger something like a re-rendering of the footer? (skip to last page button is not working either, same problem here.)

@orneryd
Copy link
Contributor

orneryd commented Apr 16, 2013

once the promise resolves a $digest shold be triggered. can you repro in a plunker?

@richtmat
Copy link
Author

here we go: http://plnkr.co/edit/tuCxztnymOF55SlGLeuj?p=preview

I have two ng-grid versions here to test. Using the old one leads to output of null, using 2.0.4 shows my initial value. Outside of the table the correct value is shown.

@richtmat
Copy link
Author

hi @timothyswt , I'm still stuck on that issue. I dug into the sources and believe that the current implementation does not allow for a change of a once set totalServerItems value. I think it is necessary because of async retrieving that value from the server and because of regular changes in datasets which would not be updated.

@ghost ghost assigned orneryd Apr 26, 2013
c0bra added a commit that referenced this issue May 3, 2013
Thanks to @keithharvery for the PR. The `totalServerItems` grid option can
once again be set to a string, which will be watched by the grid and
reflected in the footer if updated.

Also added tests to directivesSpec.js for using a normal number and using
a string.
c0bra added a commit that referenced this issue May 3, 2013
Thanks to @keithharvery for the PR. The `totalServerItems` grid option can
once again be set to a string, which will be watched by the grid and
reflected in the footer if updated.

Also added tests to directivesSpec.js for using a normal number and using
a string.
@orneryd orneryd closed this as completed Jun 4, 2013
@timothyklim
Copy link

Example http://plnkr.co/edit/4LyAek?p=preview from http://angular-ui.github.io/ng-grid/ have this bug too.

@jonricaurte
Copy link
Contributor

This is exactly what I was looking for. Now I know why they were split. "we switched out the place where totalServerItems is set because people
wanted to update it manually while watching the pagingOptions configuration
variable for changes (so they know when to retrieve more data from the
server)."

@igorcosta
Copy link

There's another issue, when I page the itens, and change page selected itens becomes null.

@varshaan0sharma
Copy link

I got this issue fixed by updating totalServerItems on every paging action $scope.setPagingData(data,page,pageSize); on success $scope.setPagingData = function(data, page, pageSize){
var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
$scope.myData = pagedData;
$scope.totalServerItems = data.length;
if (!$scope.$$phase) {
$scope.$apply();
}
};

@nkantkumar
Copy link

I used $scope.gridApi.grid.option.totaltems and it is started working

@blakerego
Copy link

I agree with @nkantkumar: $scope.gridApi.grid.option.totalItems properly sets the footer's totalItem count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants