Updating multiple rows on a large handsontable loc

2019-09-04 21:58发布

问题:

I have a handson table with 300+. It renders quickly. However, if I update one column in all rows like so:

function() {
    console.trace("Start", new Date());
    $scope.myData.forEach(function(elem, idx) {
        elem.properties.myCol = Math.random();
        if (idx % 100 == 0) console.trace("Tick", new Date());
    });
    console.trace("End", new Date());
};

The loop executes in less than a second, but the browser tab locks up and the page does not update for over a minute. Is there some way I can disable handsontable from reading updates to the array and then triggering a manual redraw? Is there any other way to speed this up?

回答1:

After updating the handsontable data you can use $('#yourTable').handsontable("render"); To re-render the handsontable manually after any updates to the data. And set observeChanges:false (It is false by default) while creating handsontable to disable automatic re-rendering by handsontable.



回答2:

The option that was slowing down rendering was columnSorting: true,. Removing this fixed the issue.