angular-ui/ui-grid

Support HTML in header

Open

#5,229 建立於 2016年3月15日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)JavaScript (5,395 star) (2,496 fork)batch import
good first issueseverity: performancetype: enhancement

描述

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.

貢獻者指南