数据源更新时,选择列表变空 - datatable materil2 [英] selection list become empty when datasource is updated - datatable materil2

查看:139
本文介绍了数据源更新时,选择列表变空 - datatable materil2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新数据源时,选择列表变空。

Selection list becomes empty when datasource is updated.

步骤:1。选择一些用户

steps: 1. select some users

步骤:2。选择第二个标签

steps: 2. select second tab

步骤:3。返回第一个标签

steps: 3. come back to the first tab

选定的用户可用在筹码中但未在数据表中选择。

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

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

推荐答案

您正在通过行对象本身保存选择状态,当您更改选择第一个时,您的loadUsers()调用都会更改这些状态标签。每次单击第一个选项卡时都不要调用loadUsers()(如果需要刷新数据,创建保存现有用户对象的updateUsers()方法),或者更改保存选择状态的方式(例如, row.id)。

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).

这篇关于数据源更新时,选择列表变空 - datatable materil2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆