Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-grid cellTemplate doesn't work with CUSTOM_FILTERS included

When including a cellTemplate in a column definition, if that cellTemplate includes CUSTOM_FILTERS, it causes angular to puke:

Error: Syntax Error: Token 'CUSTOM_FILTERS' is an unexpected token at column 14 of the expression [row.entity.1 CUSTOM_FILTERS] starting at [CUSTOM_FILTERS]

Even using the default cellTemplate in a column def results in the same error.

cellTemplate = "<div class=\"ngCellText\" ng-class=\"col.colIndex()\"><span ng-cell-text>{{COL_FIELD CUSTOM_FILTERS}}</span></div>"
like image 499
Hilo Avatar asked Feb 15 '23 08:02

Hilo


1 Answers

It turns out the ng-grid code assumes you have hard coded your custom filter into your specified cellTemplate:

self.cellTemplate = colDef.cellTemplate || $templateCache.get('cellTemplate.html').replace(CUSTOM_FILTERS, self.cellFilter ? "|" + self.cellFilter : "");

As you can see, they don't do a replace if you have specified a cellTemplate in you column def. So if you are providing a custom cellTemplate for a column and would like a cellFilter, you would do something like this:

cellTemplate = "<div class=\"ngCellText\" ng-class=\"col.colIndex()\"><span ng-cell-text>{{COL_FIELD |number:3}}</span></div>"
like image 73
Hilo Avatar answered Mar 05 '23 15:03

Hilo