Я пытаюсь заполнить DevExtreme SelectBox () (или Lookup () ) с Dictionary<string><string>
, но я получаю ошибку:
Uncaught Error: E4006 - опция ArrayStore 'data' должна быть массивом.
Модель
public string Lang { get; set; }
public Dictionary<string, string> Languages { get; }
...
this.Lang = "es";
this.Languages = new Dictionary<string, string>() { {"en", "English"}, {"ar", "Arabic"}, {"bn", "Bengali"}, {"cs", "Czech"}, {"da", "Danish"}, {"de", "German"},
{"el", "Greek"}, {"es", "Spanish"}, {"fa", "Persian"}, {"fi", "Finnish"}, {"fil", "Filipino"}, {"fr", "French"},
{"he", "Hebrew"}, {"hi", "Hindi"}, {"hu", "Hungarian"}, {"id", "Indonesian"}, {"it", "Italian"}, {"ja", "Japanese"},
{"ko", "Korean"}, {"msa", "Malay"}, {"nl", "Dutch"}, {"no", "Norwegian"}, {"pl", "Polish"}, {"pt", "Portuguese"},
{"ro", "Romanian"}, {"ru", "Russian"}, {"sv", "Swedish"}, {"th", "Thai"}, {"tr", "Turkish"}, {"uk", "Ukrainian"},
{"ur", "Urdu"}, {"vi", "Vietnamese"}, {"zh-cn", "Chinese (Simplified)"}, {"zh-tw", "Chinese (Traditional)"} };
Просмотр
@(Html.DevExtreme().Form()
.ID("form")
.FormData(Model)
.ColCount(12)
.ShowValidationSummary(true)
.Items(i =>
{
i.AddSimple()
.ColSpan(6)
.Label(l => l.Visible(false))
.DataField(Model.Lang.ToString())
.Editor(ed => ed.SelectBox()
.DataSource(Model.Languages)
.Placeholder("Language..."));
}))
Я пытался создать List
, который не возвращает ошибку, но ничего не показывает.
Модель
public string Lang { get; set; }
public Dictionary<string, string> Languages { get; }
public List<Dictionary<string, string>> List { get; }
...
this.Lang = "es";
this.Languages = new Dictionary<string, string>() { {"en", "English"}, {"ar", "Arabic"}, {"bn", "Bengali"}, {"cs", "Czech"}, {"da", "Danish"}, {"de", "German"},
{"el", "Greek"}, {"es", "Spanish"}, {"fa", "Persian"}, {"fi", "Finnish"}, {"fil", "Filipino"}, {"fr", "French"},
{"he", "Hebrew"}, {"hi", "Hindi"}, {"hu", "Hungarian"}, {"id", "Indonesian"}, {"it", "Italian"}, {"ja", "Japanese"},
{"ko", "Korean"}, {"msa", "Malay"}, {"nl", "Dutch"}, {"no", "Norwegian"}, {"pl", "Polish"}, {"pt", "Portuguese"},
{"ro", "Romanian"}, {"ru", "Russian"}, {"sv", "Swedish"}, {"th", "Thai"}, {"tr", "Turkish"}, {"uk", "Ukrainian"},
{"ur", "Urdu"}, {"vi", "Vietnamese"}, {"zh-cn", "Chinese (Simplified)"}, {"zh-tw", "Chinese (Traditional)"} };
this.List = new List<Dictionary<string, string>>() { this.Languages };
Просмотр
@(Html.DevExtreme().Form()
.ID("form")
.FormData(Model)
.ColCount(12)
.ShowValidationSummary(true)
.Items(i =>
{
i.AddSimple()
.ColSpan(6)
.Label(l => l.Visible(false))
.DataField(Model.Lang.ToString())
.Editor(ed => ed.SelectBox()
.DataSource(Model.List)
.Placeholder("Language..."));
}))