mariuszfoltak / angular2-datatable

DataTable - Simple table component with sorting and pagination for Angular2
202 stars 183 forks source link

Emit onDataFilled event for notifying when data has been recomputed #80

Open mponizil opened 7 years ago

mponizil commented 7 years ago

Hi there,

Thanks for your work on this library - I've found it to be pleasantly lightweight and flexible!

We have the use-case where we want to fetch additional data for each row when it comes into view (e.g. due to sort change, page change, new input data, etc) and I couldn't come up with a clean way to do this via onPageChange.

From what I have observed, onPageChange may fire before the latest version of mfTable.data has been computed, so some sort of nextTick would be necessary. Also this event appears to fire too often for our use case (3 times on initial render, twice when input data changes because of ngOnChanges and ngDoCheck).

Do you have any suggestions for this use case? The solution I'm submitting here seems to do the job, but certainly interested in hearing other ideas.

Happy to add tests if this does look like something you'd like to pull in.

Cheers, Misha