Paging controls at top of grid (or custom grid template?)
It's not clear from the options docs, so I thought I would ask:
Is it possible to specify a completely custom grid template? Our users have asked for the paging controls to be customized (which I have done via the footerTemplate setting) and to duplicate the paging controls at the top of the grid (I guess they want to have large pages and yet skip forward/back a lot... The db does have 280k rows with no filter).
I see the gridTemplate partial in the grid, is that the option to override?
thanks for an awesome control and all the work on it.
in theory you should be able to specify a new grid template since i use $templateCache to store all the templates now. However, What i would suggest instead is just use the same "footerTemplate" as an additional div on top by doing something like this:
<!--normal grid -->
<div ng-grid=gridOptions></div>
<!-- place it after, but use styling to move it above the grid -->
<div ng-grid-footer2="{id: gridOptions.gridId, scope: gridOptions.$gridScope"></div>
angular.directive('ngGridFooter2', ['$compile', '$templateCache', function ($compile, $templateCache) {
var ngGridFooter = {
scope: false,
compile: function () {
return {
pre: function ($scope, iElement, iAttrs) {
if (iElement.children().length === 0) {
iElement.append($compile($templateCache.get($scope.$eval(iAttrs.id) + 'footerTemplate.html'))($scope.$eval(iAttrs.scope)));
}
}
};
}
};
return ngGridFooter;
}]);
ok thanks. I was thinking of doing something along those lines as well if the grid template did not work. I appreciate the help & code snippet!
Ok, I admit that Angular directive declarations are still beyond my ability to debug :-) When I simply integrate this, I get an error:
Error: Argument 'scope' is required
at assertArg (http://localhost:8001/js/lib/angular/angular.js:1011:19)
at http://localhost:8001/js/lib/angular/angular.js:3817:25
at pre (http://localhost:8001/js/app.js:158:118)
at nodeLinkFn (http://localhost:8001/js/lib/angular/angular.js:4292:33)
at compositeLinkFn (http://localhost:8001/js/lib/angular/angular.js:3914:37)
at compositeLinkFn (http://localhost:8001/js/lib/angular/angular.js:3917:33)
at compositeLinkFn (http://localhost:8001/js/lib/angular/angular.js:3917:33)
at compositeLinkFn (http://localhost:8001/js/lib/angular/angular.js:3917:33)
at compositeLinkFn (http://localhost:8001/js/lib/angular/angular.js:3917:33)
at http://localhost:8001/js/lib/angular/angular.js:3826:46 <div ng-grid-footer2="{id: gridOptions.gridId, scope: gridOptions.$gridScope">
where app.js line 158 is this one
iElement.append($compile($templateCache.get($scope.$eval(iAttrs.id) + 'footerTemplate.html'))($scope.$eval(iAttrs.scope)));
My only guess is at the time of the pre compile, the gridOptions.$gridScope on my controller's scope is not yet defined? Our grid is unfortunately embedded in a large-ish app, but I can try and extract a plunkr if that would help.
Thinking about this a little more... I would probably not use the internal paging controls trying to duplicate them.... I would probably use bootstrap's pagination controls and just duplicate them binding to the same properties as the footer template..then the bindings are more declarative and are done at the linking phase after the grid has been instantiated.
I'm having good luck with a partial external to the grid (starting from an exact duplicate of my custom footer) but bound to either my scope variables variables (such as gridOptions.pagingOptions or gridOptions.$gridScope.xyz (such as the i18n strings)
With this too, I hope to put up an example plunkr...
I will however look at the bootstrap paging controls and compare. thanks.
Hello,
How do i put the paging control at the top of the grid. as per our requirments we don't need the paging control/footertemaplte for grid at bottom of the grid.
Please suggest.
You need to put 'duplicate' paging controls in your HTML partial outside the grid directive, in which case you can locate them as you please (we have them immediately before the grid, inside a common div)
When you duplicate the paging template (which is available in the grid source at src/templates/footerTemplate.html), you will need to update the reference to scope object either directly on your scope or via the grid scope on the options such as
{{gridOptions.$gridScope.i18n.ngShowingItemsLabel}} instead of {{i18n.ngTotalItemsLabel}}
It's a bit hacky, but it seems straightforward and works for us without any side effects that I can see so far.
oh, and then just make sure showFooter is off in your gridOptions and you will remove the grid supplied pager at the bottom
hello, thanks for the reply. i am stuck with another issue. please advise .i have raised the issue at below link: https://github.com/angular-ui/ng-grid/issues/535
Thanks-vinay
Date: Thu, 18 Apr 2013 12:20:36 -0700 From: [email protected] To: [email protected] CC: [email protected] Subject: Re: [ng-grid] Paging controls at top of grid (or custom grid template?) (#289)
oh, and then just make sure showFooter is off in your gridOptions and you will remove the grid supplied pager at the bottom
— Reply to this email directly or view it on GitHub.
@mxreppy Can you please share plunkr example for this Paging controls at top of grid or custom FooterTemplate?
Not really easy as it's embedded in our somewhat monstrous and proprietary application right now, but let me see if I can pull something together this weekend