Pagination on top and bottom
I can't figure out how to get a pagination template to show up on the top and bottom of the table. In the source, if I try this:
return element.before(paginationTemplate).after("test");
the pagination template shows up before the table, and "test" shows up after, as expected.
But if I try this:
return element.before(paginationTemplate).after(paginationTemplate);
it only shows up after the table.
In any case, ideally there would be an attribute like pagination-location="top|bottom|topAndBottom" or something to that effect.
In the meantime, any ideas how to get this working by modifying the source?
I just figured out one way to do it in the source - make two template variables, compile both, then reference the second one in after():
var paginationTemplate = angular.element(document.createElement('div')).attr('ng-include', 'templates.pagination'); var paginationTemplate2 = angular.element(document.createElement('div')).attr('ng-include', 'templates.pagination'); element.find('thead').remove(); var tbody = element.find('tbody'); element.prepend(headerTemplate); $compile(headerTemplate)(scope); $compile(paginationTemplate)(scope); $compile(paginationTemplate2)(scope); element.addClass('ng-table'); return element.before(paginationTemplate).after(paginationTemplate2);
FTR if https://github.com/esvit/ng-table/pull/184 gets merged in you'll be able to do this with <table ng-table... pagination-top pagination-bottom>
Awesome - thanks, anoek. I'll give it a try on Monday.
Now you can place pagination in any place. Look example: https://github.com/esvit/ng-table/blob/master/examples/demo28.html#L28
Even better. Thanks!
On Sat, Apr 12, 2014 at 4:47 PM, Vitalii Savchuk [email protected]:
Now you can place pagination in any place. Look example: https://github.com/esvit/ng-table/blob/master/examples/demo28.html#L28
Reply to this email directly or view it on GitHubhttps://github.com/esvit/ng-table/issues/182#issuecomment-40291352 .
Hi everyone, I tried to use the v0.3.2 in order to display pagination on the top, but it didn't work, the console shows this message even in the example#28 provided:
TypeError: Cannot read property '$on' of null at link (file:///C:/Users/user/Desktop/ng-table-master/ng-table.js:690:47) at l (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:47:124) at f (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:41:361) at l (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:47:64) at f (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:41:361) at f (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:41:378) at file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:40:434 at file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:17:364 at h.$eval (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:105:313) at h.$apply (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:106:48)
at h.$apply (file:///C:/Users/user/Desktop/ng-table-master/examples/js/angular.min.js:106:48)
Hi, I'm getting the same issue as the above comment in a clean Angular + ngTable setting.
I can't move the pagination above the table either. Can you be kind enough to show an example of placing the pagination on top? in demo28 it is still below the table
In order to avoid the 'TypeError: Cannot read property '$on' of null', you need to add the $scope to the settings object:
$scope.tableParams = new ngTableParams({ page: 1, count: 10 }, { $scope: $scope, data: data });
I ended up using
<table ng-table="tableParams" template-pagination="pagination" template-header="pagination" show-filter="false" class="table">
custom pagination template in both header and footer, hope it helps someone.
@sahanh can you explain further how you got it to work? Where is the template defined?
@realityfluxstudios you can define it within the page or external url https://gist.github.com/sahanh/8dda94cbca473ec71f48 when using external template provide the url for template-header
@sahanh thank you! :)
Are you guys able to align the pagination according to the requirement, because i'm not able to do it.
@esvit - Thanks so much for your work on this, I'm incredibly grateful! However, I might need to abandon this module if I can't get pagination on top. I understand you probably have limited time, would you be willing to talk through how you want this coded if I were to contribute this as a feature?
I see on line 651 you have
element.addClass('ng-table')
.prepend(headerTemplate)
.after(paginationTemplate);
which makes this non-configurable for users. I think parsing the entire scope for an item with data-template-pagination is probably a bad practice, but perhaps we can just do a boolean here and add a tableParams.paginationPosition = {top || bottom} option so that we can get pagination above the table. If you want the pagination template it to be fully customizable, we could talk about how you'd like that to happen, but I'd love to help out if you need it!
did anyone got this working?
@gruskada Thanks that did the trick.
Hi !
is this issue resolved ? Cause I use the version 1.0.0-beta.7, and there is no way to position the pagination on the top other than modify the directive code :
$element.after(paginationTemplate); => $element.before(paginationTemplate); on the compileDirectiveTemplates function.
By the way, the demo28 is no longer present :'(
@esvit What is the proper solution to display a pagination control at the top? You didn't merge https://github.com/esvit/ng-table/pull/184 and is referring to an out of date link to demo 28
I am also interested in how to easily and properly move the pagination controls to the top... any hint?