I created a feature for an autocomplete dropdown component.
After selecting users, their IDs are stored in the users array.
If a user is unselected, I am looking for a way to remove their ID from the array. How can this be achieved?
Additionally, is there a method to convert the array into a string format, such as "1,2" for output purposes?
Thank you for your help!
.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>