Ng-grid cellTemplate does not work with CUSTOM_FILTERS enabled

When you include cellTemplate in a column definition, if that cellTemplate includes CUSTOM_FILTERS, it calls angular for puke:

Error: syntax error: the “CUSTOM_FILTERS” token is an unexpected marker in column 14 of the expression [row.entity.1 CUSTOM_FILTERS], starting with [CUSTOM_FILTERS]

Even using the default cell cellTemplate, the same error occurs in the def column.

cellTemplate = "<div class=\"ngCellText\" ng-class=\"col.colIndex()\"><span ng-cell-text>{{COL_FIELD CUSTOM_FILTERS}}</span></div>" 
+4
source share
1 answer

It turns out the ng-grid code assumes that you hardcoded your custom filter in the specified cellTemplate:

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

As you can see, they do not replace if you specified cellTemplate in your def column. Therefore, if you provide a custom cellTemplate for a column and want 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>" 
+8
source

Source: https://habr.com/ru/post/1500823/


All Articles