聚合物1.x:如何使用dataSource函数过滤铁数据表? [英] Polymer 1.x: How to use dataSource function to filter iron-data-table?
问题描述
我想为<iron-data-table
实现此问题的公认答案中所述的dataSource
过滤功能.我的问题是此处的文档没有给出完成此操作的示例.
最终,我希望对大型项目数据集使用一组复杂的过滤器(例如:控制面板).
Eventually, I will want to have a complex set of filters (think: control panel) on a large data set of items.
我尝试复制dom-repeat
中描述的方法.此处的文档,但没有成功.
I have tried copying the approach employed by dom-repeat
described in the docs here but without success.
<iron-data-table
items="[[users.results]]"
data-source="source(item)">
...
source: function(item) {
return item.user.name.first.length > 6;
},
如何正确实现dataSource
属性功能以过滤<iron-data-table
的项目?
How do I correctly implement the dataSource
property function to filter the items of <iron-data-table
?
推荐答案
dataSource
属性将函数作为值,所以最简单的方法是在父元素中定义函数属性并使用普通的Polymer绑定将其传递下来.
The dataSource
property takes a function as a value, so the most straight-forward way is to define a function property in your parent element and use normal Polymer bindings to pass that down.
不幸的是,函数签名的定义不是很好,但是在iron-data-table
演示页面中有一些示例:
The function signature isn't unfortunately very well defined, but there are some examples in the iron-data-table
demo pages: http://saulis.github.io/iron-data-table/demo/ (remote data example)
我已经相应更新了您的Plunkr: http://plnkr.co/edit/VWIAvWAnuf2aiCjJjCdI? p =预览
I've updated your Plunkr accordingly: http://plnkr.co/edit/VWIAvWAnuf2aiCjJjCdI?p=preview
这篇关于聚合物1.x:如何使用dataSource函数过滤铁数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!