Templates 聚合物模板重复群
有没有一种方法可以在聚合物重复模板中进行分组?我有一个带有doc.name和doc.manualType的项目列表,但我想对项目列表进行分组,以便manualType在每组中只显示一次,而不是针对每个项目 或者,如何更新绑定,使其具有以前的manualType,以便仅当manualType与以前的manualType不同时才能显示manualTypeTemplates 聚合物模板重复群,templates,polymer,repeat,web-component,Templates,Polymer,Repeat,Web Component,有没有一种方法可以在聚合物重复模板中进行分组?我有一个带有doc.name和doc.manualType的项目列表,但我想对项目列表进行分组,以便manualType在每组中只显示一次,而不是针对每个项目 或者,如何更新绑定,使其具有以前的manualType,以便仅当manualType与以前的manualType不同时才能显示manualType <template id="docListTemplate" bind="{{searchResults}}"> <div
<template id="docListTemplate" bind="{{searchResults}}">
<div class="vGroup">
<core-selector id="selector" class="list" multi selected="{{multiSelected}}">
<template repeat="{{doc, i in data}}" {previousManualType:''}>
<template if="{{doc.manualType!=previousManualType}}">
<h1>{{doc.manualType}}</h1>
</template>
<div class="cb item">
{{doc.name}}
</div>
</template>
</core-selector>
</div>
</template>
那怎么办
<template id="docListTemplate" bind="{{searchResults}}">
<div class="vGroup">
<core-selector id="selector" class="list" multi selected="{{multiSelected}}">
<template repeat="{{manualType in ManualTypes}}">
<template repeat="{{doc, i in manualType.data}}">
<h1>{{doc.manualType}}</h1>
<div class="cb item">
{{doc.name}}
</div>
</template>
</core-selector>
</div>
</template>
您需要相应地准备数据结构。正如Gunter指出的,数据结构似乎是关键。 如果无法控制输入,则需要对其进行转换。 您可以将用户下划线/lodash添加到groupBy
我无法更改数据结构,因为我正在从JSON web服务提取数据。有没有办法使用计算属性更新以前的ManualType?Polymer 0.5.1在核心列表中添加了实验分组,但它仍然要求首先正确设置数据结构。