2010-02-11 54 views
3

我無法添加任何選項到我的FilteringSelect dijit。Dojo FilteringSelect:無法添加選項

這裏是我的代碼:

var options = { 
     identifier: 'abbr', 
     label: 'name', 
     items: [{ 
      abbr: 'ec', 
      name: 'Ecuador', 
      capital: 'Quito' 
     }, 
     { 
      abbr: 'eg', 
      name: 'Egypt', 
      capital: 'Cairo' 
     }, 
     { 
      abbr: 'sv', 
      name: 'El Salvador', 
      capital: 'San Salvador' 
     }, 
     { 
      abbr: 'gq', 
      name: 'Equatorial Guinea', 
      capital: 'Malabo' 
     }, 
     { 
      abbr: 'er', 
      name: 'Eritrea', 
      capital: 'Asmara' 
     }, 
     { 
      abbr: 'ee', 
      name: 'Estonia', 
      capital: 'Tallinn' 
     }, 
     { 
      abbr: 'et', 
      name: 'Ethiopia', 
      capital: 'Addis Ababa' 
     }] 
    }; 


var headerSelect = new dijit.form.FilteringSelect({ 
name: 'test', 
id: 'widgetHeaderSelect', 
store: options 
}, 'widgetHeaderSelectDiv'); 

任何想法?感謝:D

回答

2

我相信你需要包裝你的JSON options變量在一個Dojo ItemFileReadStore

你可以嘗試類似以下的東西嗎?

var headerSelect = new dijit.form.FilteringSelect(
    { name: 'test', id: 'widgetHeaderSelect', 
     store: new dojo.data.ItemFileReadStore({ data: options }) }, 
     'widgetHeaderSelectDiv'); 

Dojo Campus還有一個使用本地JSON結構的編程示例。它是Codependent FilteringSelect Example(在該鏈接之後的第五個「查看示例」按鈕)。