纳克栅cellTemplate不与包括CUSTOM_FILTERS工作 [英] ng-grid cellTemplate doesn't work with CUSTOM_FILTERS included

查看:211
本文介绍了纳克栅cellTemplate不与包括CUSTOM_FILTERS工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在包括列定义一个cellTemplate,如果cellTemplate包括CUSTOM_FILTERS,它会导致角想吐:

错误:语法错误:令牌'CUSTOM_FILTERS'是在除权pression的14列一个意外标记[row.entity.1 CUSTOM_FILTERS]开始[CUSTOM_FILTERS]

即使使用在相同的错误列DEF结果默认cellTemplate。

  cellTemplate =< D​​IV CLASS = \\ngCellText \\纳克级= \\col.colIndex()\\><跨度NG信文本> { {COL_FIELD CUSTOM_FILTERS}}< / SPAN>< / DIV>中


解决方案

原来,吴格code假设你已经很难codeD您的自定义过滤器到你指定的cellTemplate:

  self.cellTemplate = colDef.cellTemplate || 。$ templateCache.get('cellTemplate.html')取代(CUSTOM_FILTERS,self.cellFilter|+ self.cellFilter:);

正如你所看到的,他们不这样做,如果你已在你列DEF指定cellTemplate一个替代。所以,如果你正在为一列自定义cellTemplate,想一个cellFilter,你会做这样的事情:

  cellTemplate =< D​​IV CLASS = \\ngCellText \\纳克级= \\col.colIndex()\\><跨度NG信文本> { {COL_FIELD |数:3}}< / SPAN>< / DIV>中

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>"

解决方案

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>"

这篇关于纳克栅cellTemplate不与包括CUSTOM_FILTERS工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆