Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving performance setting widget data. #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/knockout-kendo-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,20 @@ ko.kendo.setDataSource = function(widget, data, options) {
widget.setDataSource(data);
return;
}

if (!options || !options.useKOTemplates) {
/*
options.dataIsSimpleJS is a simple property extending the binding options.
The reason for adding this property is to avoid unnecessary iteration/subscriptions through a possibly large dataset.
If we have a large dataset say > 35000 items the performance hit is quite big. Some browsers are not very forgiving (FF) and display non responsive script error.
If the consumer knows that his data are consisted by simple js objects , he can just set the new flag to true to avoid the iteration.

We could use the useKOTemplates to achieve the same , but it is not clear to me how that would affect now or in a future version consumer implementations.
Having an option decicated for this usage is the cleanest way to address this issue.
Here is a fiddle to demonstrate the performance difference using the useKOTemplates
http://jsfiddle.net/gtrifidis/mC4Vw/14/
Just remove the useKOTemplates from the binding to see it.
*/

if (!options && (!options.dataIsSimpleJS || !options.useKOTemplates)) {
isMapped = ko.mapping && data && data.__ko_mapping__;
cleanData = data && isMapped ? ko.mapping.toJS(data) : ko.toJS(data);
}
Expand Down