selection list become empty when datasource is updated - datatable materil2

我与影子孤独终老i 提交于 2019-12-08 11:35:08

问题


Selection list becomes empty when datasource is updated.

steps: 1. select some users

steps: 2. select second tab

steps: 3. come back to the first tab

selected users are available in chips but not selected in datatable.

look at https://stackblitz.com/edit/angular-v3kjgj?embed=1&file=app/selectusers.component.ts


回答1:


You are saving selection status by the "row" object itself, which are all changed by your loadUsers() call when you change select the first tab. Either don't call loadUsers() every time you click on the first tab (if you need to refresh data, create an "updateUsers()" method that keeps the existing user objects), or change how you save selection status (e.g. by row.id).



来源:https://stackoverflow.com/questions/49045049/selection-list-become-empty-when-datasource-is-updated-datatable-materil2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!