1

我想为用户找到在 Ember 中尽可能快速流畅地过滤大型数据集的最佳解决方案。

这是一个在 2500 个名称列表上短暂锁定搜索的示例。例如,尝试以“A”开头的搜索。

http://jsbin.com/ulukep/26/edit

(如果解决方案使用https://github.com/emberjs/list-view则加分)

4

1 回答 1

3

让它感觉慢的不是搜索/过滤,而是实际呈现结果。Ember 列表视图是一个很好的解决方案,很容易将它添加到您的示例中。

添加 ember-list-view 库和所需的 css:

<script src="http://builds.emberjs.com/list-view/list-view-latest.js"></script>
<style>
.ember-list-view {
  overflow: auto;
  position: relative;
}
.ember-list-item-view {
  position: absolute;
}
</style>

用 ember-list-view替换模板中的把手{{each}}块,仍然view.filteredList用作内容:

{{#collection Ember.ListView contentBinding="view.filteredList" height=100 rowHeight=20 width=500}}
  {{name}}
{{/collection}}

而已。现在以“A”开头的搜索返回闪电般的速度,没有任何锁定。在这里试试:http: //jsbin.com/ulukep/27

于 2013-08-03T07:01:34.727 回答