聚合物1.x:如何使用dataSource函数过滤铁数据表? [英] Polymer 1.x: How to use dataSource function to filter iron-data-table?

查看:96
本文介绍了聚合物1.x:如何使用dataSource函数过滤铁数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是朋克.

我想为<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屋!

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