2017-09-08 9 views
0

選択リストの重複オプションを非表示にしたい。 この意味を理解するために、exampleを参照してください。今は、重複したオプションのうちの1つしか選択できませんが、それでも表示されます。重複する反応選択オプションを非表示にする

私はCSSを使用してそれらを非表示にしようとしました。

データ:

const ERRORS = [ 
 
    { 
 
     id: 1, 
 
     customer: "Testcompany 1", 
 
     sender: "Lars Olsen", 
 
     title: "Conference Papers", 
 
     body: "I don't know how this works...", 
 
     predicted: 22, real: 34, 
 

 
    }, 
 
    { 
 
     id: 2, 
 
     customer: "Testcompany 1", 
 
     sender: "Stine Nilsen", 
 
     title: "Expense Reports", 
 
     body: "I need some help with the expense reports...", 
 
     predicted: 13, real: 31, 
 
    }, 
 
    { 
 
     id: 3, 
 
     customer: "Testcompany 1", 
 
     sender: "Steinar Trolo", 
 
     title: "Server Fail", 
 
     body: "My server is failing. Please help.", 
 
     predicted: 13, real: 31, 
 
    }, 
 
    { 
 
     id: 4, 
 
     customer: "Testcompany 1", 
 
     sender: "Steinar Trolo", 
 
     title: "Server Fail", 
 
     body: "My server is failing. Please help.", 
 
     predicted: 13, real: 31, 
 
     label: "Second" 
 
    }, 
 
    { 
 
     id: 5, 
 
     customer: "Testcompany 2", 
 
     sender: "Steinar Trolo", 
 
     title: "Server Fail", 
 
     body: "My server is failing. Please help.", 
 
     predicted: 13, real: 31, 
 
    } 
 
]

選択コンポーネント:

<Select 
 
    options={ERRORS} 
 
    value={this.state.selectValue} 
 
    onChange={this.updateValue.bind(this)} 
 
    searchable 
 
    labelKey="customer" 
 
    valueKey="customer" 
 
/>

答えて

0

あなただけの明確なお客様に提供したい場合は、補遺屋なLodashのように唯一の明確な顧客のリスト:可能な混乱を避けるため

options={_.uniqBy(ERRORS, (e) -> (e.customer))}

、おそらくいない重複顧客とのランダムなオブジェクトのリストを与えないことが好ましいであろう、とだけのリストを提供します別個の顧客。 ; senderArr.push(error.sender); titleArr.push(error.title) ERRORS.map((エラー)=> { customerArr.push(error.customer):私はこれを使用して設定を試みた

+0

; }); let uniqueCust = [... new Set(customerArr)]; オプションにはラベルと値が必要なので、このユニークな配列の使用方法はまだわかりません... – markusjs

関連する問題