亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從下拉列表中過濾重復值

從下拉列表中過濾重復值

偶然的你 2022-12-29 16:16:46
我有一個 ColumnDef:  relatedToolsColumns: ColumnDef[] = [  { field: 'toolId', name: 'Tool Number', type: 'dropdown', optionsList: this.tools, optionsListField: 'id', optionsListName: 'toolNo', width: '70%' },  {     field: 'delete', name: 'Delete', type: 'icon-button', width: '30%', sortingDisabled: true, icon: 'delete',     callback: this.deleteRelatedTool.bind(this)  }];我正在使用端點調用“getGageNoList”訂閱這些工具: ngOnInit() {  this.tool = this.data.tool;  this.readonly = this.data.readonly;   this.tprecmApiService.getGageNoList()     .subscribe((val) => {        this.tools = val;        this.relatedToolsColumns           .find((column: ColumnDef) => column.field === 'toolId')           .optionsList = this.tools;     });  }這就是我所擁有的工具: 工具數組這就是我在工具顯示的 UI 中所擁有的,當前從下拉列表中選擇了兩個相同的工具編號。 UI 添加工具顯示The Dropdown list of tools: 網格中工具的下拉列表我需要將這些下拉列表過濾為僅那些尚未顯示在網格上的下拉列表。
查看完整描述

2 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

this.tools.filter((tool, index, arr) => arr.findIndex(t => t.toolNo === tool.toolNo) === index)

將為您提供一個數組,其中與之前的工具編號相同的工具被過濾掉,因為 findIndex 返回與該函數匹配的第一個項目。


查看完整回答
反對 回復 2022-12-29
?
桃花長相依

TA貢獻1860條經驗 獲得超8個贊

用一些小的js你可以過濾它們

if (!(dropdownTool in toolsArray)) { ... } // push to array you send to HTTML to loop in



查看完整回答
反對 回復 2022-12-29
  • 2 回答
  • 0 關注
  • 102 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號