2017-01-06 5 views
0

私のドロップダウンリストは、値の代わりに[オブジェクト] [オブジェクト]を返しています。私はSQLテーブルから値を取得しています。どんな援助も素晴らしいだろう。前もって感謝します。あなたがそれらのオブジェクトをどのように解釈するかを言わずにオブジェクトの配列へのドロップダウンを結合しているSQLのテーブルから値の代わりに[オブジェクトオブジェクト]を表示するドロップダウンリスト

のviewmodel

vm.addObservables('selected'); 
vm.addObservableArrays('list'); 

_Integration.GetAll('sqlTable').then(function(vals){ 
     vm.list(vals); 

}); 

HTML

<select id="dropDown" name="dropDown" 
    data-bind='options: list, 
       value: selected, 
       optionsCaption: "Choose...", 
       autoSave: true'> 

</select> 

答えて

2

。 data-bind optionsText: 'fieldName'を追加します.fieldNameは、表示するオブジェクト上のプロパティの名前です。

http://knockoutjs.com/documentation/options-binding.html

サンプル:

<select data-bind="options: availableCountries, 
        optionsText: 'countryName', 
        value: selectedCountry, 
        optionsCaption: 'Choose...'"></select> 
関連する問題