0

I'm using angular-material table in angular and I wrote a function that is triggered by clicking on a row in my angular-material table.

The function highlights the row that was clicked, but because I'm getting a lot of changes in the rows the click event doesn't work very good,
I'm getting a new data every second and if I'm clicking the row in the period of time that the data is changing it doesn't click (the row not getting highlighted).

Ruli
  • 2,592
  • 12
  • 30
  • 40
Yarin
  • 1

1 Answers1

0

General approach in these situations : If you want to change data on click of table's row, and due to server side call it takes some time, a better way is to do not wait for server side response to update the table.

What you can do is just send a call to backend separately, and validate data in front-end that its good then update the table row manually using modal.
Once the backend response is come, if its success then good, and by chance if it fails, then show a message and revert the row data.

This way your table data will be updated instantly. For more clarity you can add a small message on screen also that changes are being saved.

abhinav3414
  • 946
  • 3
  • 9
  • 31
  • I dont want to change the data of the row by click , the data changed from the server is automatically but i do want that by click the highlight function that i triggered from the click will happend , it often dont happened cus of the data change of the row , if i stop the data stream and thw table is stable the click even and my function works well... – Yarin Sep 02 '21 at 12:10
  • Cann't in your case we collect data from observable and do not update it every second on table, but collect data for some time (maybe 1-2 minutes) and then update table every once in a while. – abhinav3414 Sep 02 '21 at 13:31