Knockout performance issues with arrays with dynamic columns

I am using knockout.repeat to draw a dynamic array of columns with the following data:

var columns = ko.observableArray([
    new Column(1),
    new Column(2),
    new Column(3),
    new Column(4),
    new Column(5)
});

var array = ko.observableArray([1..95]);

      

The data is assigned the following form with knockout display:

mappingConfig = {
    create: function (options) {
        return new Row(options.data);
    }
};
ko.mapping.fromJS(data, mappingCOnfig, array);

      

In the following way:

<div data-bind="repeat: {foreach: array, item: '$row'}">
        <div data-bind="repeat: {foreach: column, item: '$col'}">
            <input data-bind="value: $row()[$col().Name]"/>
        </div>
    </div>

      

The problem is that it takes about 30 seconds to render 95 rows with six columns .

  • How can I fix this problem?
  • Are there any tools?
  • Are there any guidelines on how to maximize performance in similar scenarios?

Chrome timeline: enter image description here

UPDATE: I was under pressure so I rewrote the tables in reactjs which solved a lot of problems and rendered in just 1.5 seconds.

+3


source to share


1 answer


You can use Chrome's troubleshooting tools, specifically Profiles , Network and Timeline in your case.



Please enable JSFiddle with reproduction and it will be easier for you to use this issue.

-1


source







All Articles