数组过滤器返回数据的速度很慢 [英] Array filter is returning data very slowly
问题描述
我正在使用敲除arrayfilter来过滤项目.但是,如果有1000条以上的记录,那么它返回数据的速度将非常缓慢.我该怎么办?这是我的方法
I am using knockout arrayfilter to filter items. But if there are more than 1000 records then it returns data very slowly. What should i do for it? Here is my method
viewModel.filteredData = ko.computed(function () {
var str = "<temp>";
if (viewModel.selection() == "All") return viewModel.dataOne();
return ko.utils.arrayFilter(viewModel.dataOne(), function (data) {
stringFromArray = data.display;
if (stringFromArray.indexOf(str) == 0) {
return true;
}
});
});
这是我的小提琴
当我选择选项按钮全部"时,它将加载所有数据,如果我选择已选择",则它将过滤记录.现在,我的小提琴中没有太多记录,因此它的过滤非常快. 但是在我的实际应用程序中,我有5000多个记录,并且要花10秒才能显示所有记录.我的意思是我从服务中加载数据并加载了数据,并选择了全部"选项按钮. 然后,我选择已选择"选项按钮,它会在3-5秒内过滤记录.现在,当我再次单击全部"选项按钮时,需要10秒钟来重新加载数据.我如何提高速度.
When i select option button "All" then it will load all the data and if i select "Selected" then it will filter record. Right now i dont have much records in my fiddle so its filtering pretty fast. But in my real life application i have more than 5000 records and it takes 10 seconds to show All records. What i mean is i load data from my service and data is loaded and option button "All" is selected. Then i select "Selected" option button which filters record in 3-5 seconds. Now when i again click on "All" option button then it takes 10 seconds to reload data. How could i improve speed.
我还在此处了解了有关问题,但无法理解
I also read about question here but was not able to understand it.
更新1
我决定进行服务器端分页.有人可以给我链接以使用kogrid进行服务器端分页吗?我正在使用WCF服务来检索数据.我是否需要每次调用时都将pagesize参数传递给服务.让我知道是否有使用wgrid服务使用kogrid的示例.
I have decided to do server side paging. Can someone give me links to do server side paging using kogrid? I am using WCF services to retrieve data. Do i need to pass pagesize parameter to service everytime when its called. Do let me know if there is any example using kogrid with wcf service.
推荐答案
也许此链接会为您提供帮助.
May be this link here will help you..
这是设置视图模型以启用分页的方法.
This is how you would set up your viewmodel to enable paging.
这里的链接
将帮助您获得WCF服务.当然,该数据将是来自第一个链接的分页数据.
would help you get your WCF service work. Of course, the data would be the paging data from the first link.
这篇关于数组过滤器返回数据的速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!