Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get angular ui grid footerTemplate to work?

Angular UI-Grid has a property called footerTemplate, which is supposed to offer the possibility to create a custom footer template. I tried entering html content (a div with some text) in a string, I've also tried adding a .html file name in the string and even the ID of a rendered div, but none of them seem to work. It also wasn't clear for me if I need to enable showGridFooter for this or not, so I tried both, but the footerTemplate is either not shown at all, or if I set showGridFooter to true, it shows the default footer (total lines in the grid). What am I missing here?

like image 670
Cox Szg Avatar asked Mar 05 '15 09:03

Cox Szg


3 Answers

For angular-ui-grid 3.0.x it's working with the following example options:

$scope.options = {
                   showGridFooter: true,
                   gridFooterTemplate: '<div>pink floyd</div>'
};

For the 2.x ng-grid versions, Mokgra's version is good.

like image 93
radusezciuc Avatar answered Oct 15 '22 06:10

radusezciuc


Try enclosing the footer template inside div tag like

 $scope.gridOptions = {
            showGridFooter: true,
            gridFooterTemplate: "<div>Message Here</div>"
    }

if you want to show any scope variable

$scope.SomeScopeVariable = "Message Here";

$scope.gridOptions = {
        showGridFooter: true,
        gridFooterTemplate: "<div>Grid Footer: {{grid.appScope.SomeScopeVariable}}</div>"
}

grid.appScope allows access to scope variables in templates. tested with angular-ui-grid 3.0.x

like image 34
Abhimanyu Ghei Avatar answered Oct 15 '22 06:10

Abhimanyu Ghei


I updated my version of ui-grid to the "pre-beta" 3.x and now I'm at the same point you are. Using 'showGridFooter' set to true will show total rows info automatically. Specifying a 'footerTemplate' doesn't do anything. I've tried with both 'showGridFooter' and 'showFooter' present and absent. So the following paragraph of my answer only works for the 2.x "stable" version of ui-grid.

Wierdly, showFooter property needed set to true. What worked for me is to add an html file to my project that contained a div full of goodies (like you were thinking). Seems like a bug. showGridFooter property didn't work for me.

$scope.gridOptions1 = {
    showFooter: true,
    footerTemplate:'somePath/footerTemplate.html'
}
like image 2
Mokgra Avatar answered Oct 15 '22 07:10

Mokgra