swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

Row select delayed after scrolling when using virtual scrolling #1371

Open eickhardt opened 6 years ago

eickhardt commented 6 years ago

**I'm submitting a ...

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior I have a table with 40 rows using virtual scrolling and paging client side. I click a row and it becomes selected. Then I scroll to the bottom of the table and back up to the top 5 consecutive times. Now when I click a row it becomes selected, but only after more than 1 second. This delay is a problem, because we use that selection to control other components.

Expected behavior Instantly select the clicked row without delay, also after any amount of scrolling.

What is the motivation / use case for changing the behavior? We want to be able to quickly select a row and execute some other action based on that instantly after.

Please tell us about your environment: Windows 7 Enterprise, Visual Studio Code

ChenTek commented 6 years ago

I'm having the same issue. Any work around?

zena200 commented 6 years ago

I am also experiencing same issue. Any ideas would be greatly appreciated.

eickhardt commented 6 years ago

Found a workaround using the zone:

    import { NgZone } from '@angular/core';

    constructor(private _zone: NgZone) {}

    public onSelect(event: any): void {
        // "Zone" needed to fix ndx-datatable slow selection after scrolling
        this._zone.run(() => {
            this.selectionChanged.emit(event);
        });
    }
zena200 commented 6 years ago

Found resolution in issue #1264 by downgrading to version 11.0.4 .

mrtbyram commented 5 years ago

Below workaround worked for me in version 11.0.4. A mouse click on anywhere in screen solves the problem. So you can click to container div or directly on table when check box changed.

onCheckBoxChange(){
    document.getElementById(<elementId>).click();
}
evilstiefel commented 4 years ago

We are facing the same issue, using virtual scrolling. It seems to me like the events that are attached on each row don't get cleaned up when the element gets removed and reattached to the DOM? It will get worse over time. The above hints don't help us in fixing the problem unfortunately.

This makes virtual scrolling a neat feature, but practically unusable.