简体   繁体   English

聚合物铁清单显示过时的项目

[英]Polymer iron-list showing outdated items

I have an iron-list element with about 500 items in it and have implemented a filter function (like the one in How to filter an iron-list in polymer 1.0? ). 我有一个大约有500个项目的铁清单元素,并实现了过滤器功能(例如如何在聚合物1.0中过滤铁清单中的那个)。 Showing and filtering items works good, except when my filter gets too restrictive: in that case some items are shown that do not match the current filter but the one before that. 显示和过滤项目的效果很好,除非我的过滤器的限制过于严格:在这种情况下,显示的某些项目与当前过滤器不匹配,但与当前过滤器不匹配。 To my understanding - when the number of items in iron-list decreases - already created displayed (virtual) items are not get deleted. 据我了解-当铁清单中的项目数量减少时-已经创建的显示(虚拟)项目不会被删除。

Example: The items {A, B, C, D, E, F, G, H, I} match filter X. The iron-list element has 5 virtual elements (simplified markup): 示例:项{A,B,C,D,E,F,G,H,I}与过滤器X匹配。Iron-list元素具有5个虚拟元素(简化标记):

<iron-list>
    <div>A</div>
    <div>B</div>
    <div>C</div>
    <div>D</div>
    <div>E</div>
</iron-list>

Then I change the filter to Y with only H and I as matching items: The updated markup looks like this: 然后,将过滤器更改为Y,仅将H和I作为匹配项:更新的标记如下所示:

<iron-list>
    <div>H</div>
    <div>I</div>
    <div>C</div>
    <div>D</div>
    <div>E</div>
</iron-list>

I expected only two div elements within the iron-list but it seems to keep a constant number of virtualized items. 我希望铁表中只有两个div元素,但似乎保留了恒定数量的虚拟化项目。 I tried to update the element by invoking notifyResize() and other methods (see https://www.webcomponents.org/element/PolymerElements/iron-list/elements/iron-list ) but with no effect. 我试图通过调用notifyResize()和其他方法来更新元素(请参阅https://www.webcomponents.org/element/PolymerElements/iron-list/elements/iron-list ),但没有任何效果。

Any ideas, apart from manually delete the spare virtual elements? 除了手动删除备用虚拟元素外,还有其他想法吗?

Obviously iron-list adds a "hidden" attribute to virtual elements that should not be visible - which I did not notice before. 显然,铁列表为虚拟元素添加了“隐藏”属性,这些属性不应该可见-我之前从未注意到。

So adding a CSS directive like 所以添加一个CSS指令,例如

#list .item[hidden] { display: none; }

solves the problem mentioned above. 解决了上述问题。

I don't think there is another options beside deleting manually the array or using notifyResize. 我认为除了手动删除数组或使用notifyResize之外,没有其他选择。 Obviously I would go for the second. 显然我会去第二次。

Without seeing your code I don't know why it does nor work for you, but here is a similar situation using notifyResize. 没有看到你的代码,我不知道为什么它也不是为你工作,但这里是用notifyResize类似的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM