Hi, I have created a dropdown list inside the editor template folder for an asp net core 2 project.
The dataSource comes from a viewbag collection.
This is the dropdown definition:
<ejs-dropdownlist id="@ViewData.ModelExplorer.Metadata.PropertyName" allowFiltering="true" dataSource="@ViewData[collectionName]" value="@Model">
<e-dropdownlist-fields text="Text" value="Value" />
</ejs-dropdownlist>
This is the collection:
Value | Text |
1 | Red |
10 | Blue |
21 | Green |
43 | Purple |
In Create mode everything is working. The list is filled and the correct value is returned.
When I go in Edit mode, the selected value is passed to the template, because @Model contains it, but the dropdown doesn't show the corresponding text.
If I confirm the view, the correct value is posted back to the controller. This means that the dropdown knows the current value, but it doesn't diplay the associated data.
The dropdown contains the elements, because the page code contains this at the bottom and I can see them if I open the dropdown:
var DropDownListqzmnpn3x1hp=new ejs.dropdowns.DropDownList({
"allowFiltering": true,
"dataSource": ejs.data.DataUtil.parse.isJson([....
For testing, if I set the index property it selects an item, but it's not the correct one, because index starts from 0 to collection.count - 1, while the value passed to the template is the value of the selected item (1, 10, 21 or 43).
So, how can I set and display the default value when the view is loaded?
Thanks, Marco