Knockoutjs - Sorting a large observablearray

北战南征 提交于 2020-01-04 02:09:21

问题


I have a knockout model defined on a page with an observable array. I would like to have buttons to sort the array by different properties, I have a 'working' solution but it is extremely slow for large arrays.

jsFiddle - http://jsfiddle.net/7JNrc/

What is the most efficient way to sort a knockout observable array of objects by specific properties?


回答1:


Your solution is slow not due to the sorting. It is slow because you bind a lot of items to one page. It takes much time to render 200 items. Moreover your solution is not user friendly. It is very uncomfortable to work with big list without pagination and searching.

So my advice is to use pagination in your list. In this case you will not have any performance issues.

Here is an example of simple client side pagination: Client-Side Pagination



来源:https://stackoverflow.com/questions/12743265/knockoutjs-sorting-a-large-observablearray

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!