angular-ui/ui-grid

Support HTML in header

Open

#5,229 opened on Mar 15, 2016

View on GitHub
 (0 comments) (0 reactions) (0 assignees)JavaScript (5,395 stars) (2,496 forks)batch import
good first issueseverity: performancetype: enhancement

Description

Hi -

This is an enhancement request. A small change in the default header cell template would allow HTML formatted headers. Instead of the mustache, use ng-bind-html. ng-bind is also recommended over brackets and has better performance. I am successfully using the code/hack below.

    var h = $templateCache.get('ui-grid/uiGridHeaderCell');
    h = h.replace('>{{ col.displayName CUSTOM_FILTERS }}', ' ng-bind-html="col.displayName CUSTOM_FILTERS">');
    $templateCache.put('ui-grid/uiGridHeaderCell', h);

See it work in a plunk based on your custom filter demo: http://plnkr.co/edit/AN4Kk5?p=info


Small update: Also requires mod to uiGridMenuItem template to display HTML names in grid menu along these lines:

    var m = $templateCache.get('ui-grid/uiGridMenuItem');
    m = m.replace('{{ name }}', '<span ng-bind-html="name"></span>');
    $templateCache.put('ui-grid/uiGridMenuItem', m);

Of course instead of these hacks the template HTML should just be changed accordingly. Until that time this is an attempt to be drop-in upgrade compatible.

Contributor guide