Datalist returns null from block settings
See original GitHub issueWhat is the current behaviour?
We have a custom data source to select some devices / screen resolutions to hide some block elements, where we use some block settings.
public class DeviceDataSource : IDataListSource, IDataListSourceValueConverter
{
private readonly Dictionary<string, DeviceType> _lookup;
public DeviceDataSource()
{
var devices = new List<DeviceType>
{
new DeviceType {
Name = "Mobile",
Key = "mobile",
Icon = "icon-iphone",
},
new DeviceType {
Name = "Tablet",
Key = "tablet",
Icon = "icon-ipad",
},
new DeviceType {
Name = "Desktop",
Key = "desktop",
Icon = "icon-display",
},
};
_lookup = devices.ToDictionary(x => x.Key.ToString());
}
public string Name => "Devices";
public string Description => "Data source for devices.";
public string Icon => "icon-brick";
public OverlaySize OverlaySize => OverlaySize.Small;
public Dictionary<string, object> DefaultValues => default;
public IEnumerable<ConfigurationField> Fields => default;
public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
{
return _lookup
.Select(x => new DataListItem
{
Name = x.Value.Name,
Value = x.Key,
Icon = x.Value.Icon,
Description = ""
});
}
public Type GetValueType(Dictionary<string, object> config) => typeof(DeviceType);
public object ConvertValue(Type type, string value) => _lookup.ContainsKey(value) == true ? _lookup[value] : null;
}
public class DeviceType
{
public string Name { get; set; }
public string Key { get; set; }
public string Icon { get; set; }
}
In this use-case the content types also vary by culture, but not the element types or block settings.
This works fine when using the property directly on a Settings node (which vary by culture). However if accessing the property from a Settings element type on a block element placed in Block List on a Standard Page (which vary by culture) the property returns null instead of the selected items.
What is the expected behaviour?
The property on either block content or block settings to return the selected items.
Please tell us about your set-up:
- Contentment version: [1.4.2]
- Umbraco version: [8.9.0]
- Umbraco ModelsBuilder is: [enabled]
- Browser: [all]
Anything else?
Settings node
Block element settings
Block element
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
How can I make a browser display all datalist options when ...
So if you already have value in input then nothing will be shown in datalist options except that value if it exists. It...
Read more >Datalist help! - HTML
Hi guys! I'm having an issue on the 'forms's practice in HTML where i'm doing the make a story project. It was all...
Read more >How to hide datalist of column value is null
Solution 1 ; grdprof" runat= ; server" OnItemDataBound= ; grdprof_ItemDataBound"> <ItemTemplate> <div> <%# Eval( ; %> <asp:Image ID= ; Image4" ...
Read more ><datalist>: The HTML Data List element - MDN Web Docs
The <datalist> HTML element contains a set of <option> elements that represent the permissible or recommended options available to choose ...
Read more >HTML5 Datalist: What You Need To Know
Datalists are author-provided lists of suggestions that are always displayed regardless of previous input. One caveat is that setting the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bjarnef FYI, released v1.4.3.
@leekelleher oh, that is beautiful, just what I need 😎 Combined with custom SVG icons that’s a pretty cool feature. #h5yr 🙌👏