我开发了一个自动完成下拉菜单。
当我选择用户时,我将 ID 存储在 users 数组中。
当我选择一个用户时,它被添加到数组中,但是当取消选择用户时,有没有办法将它从数组中删除?我怎样才能做到这一点?
还有一种方法可以将数组转换为字符串,以便输出字符串,例如:“1,2”?
.ts
users:any [] =[];
itemSelectionChanged(e){
console.log("item",e)
if(e.itemData.selected == true){
this.users.push(e.itemData.ID);
console.log(this.users)
//output as a string and not an array.... like "1,2"
}
else{
//Remove the unselected value in the array this.users e.itemData.ID
}
}
.html
<dx-drop-down-box [(value)]="treeBoxValue" valueExpr="ID" displayExpr="name" placeholder="Select a value..."
[showClearButton]="true" [dataSource]="treeDataSource" (onValueChanged)="syncTreeViewSelection()">
<div *dxTemplate="let data of 'content'">
<dx-tree-view [dataSource]="treeDataSource" dataStructure="plain" selectionMode="multiple"
showCheckBoxesMode="normal" [selectNodesRecursive]="false" displayExpr="name" [searchEnabled]="true"
[selectByClick]="true" (onItemSelectionChanged)="itemSelectionChanged($event)">
</dx-tree-view>
</div>
</dx-drop-down-box>
长风秋雁
UYOU
胡说叔叔
相关分类