Data List: Custom Value Converters
See original GitHub issueOpening an issue to follow on from a discussion with @abjerner on commit 6dd0b4d4b31aa402d5d610c42e4b244114d328df.
Is your feature request related to a problem? Please describe.
@greystate asked on the forum if it was possible for the built-in XML data source could return additional meta-data from the selected value? e.g. the Name
, Icon
, etc.
Currently only the Value
is stored against the property, and that’s the value returned on the front-end. However we do have an interface IDataListSourceValueConverter
for enabling custom object-types and values, e.g. for Enums (and in upcoming v1.1 an IPublishedContent
for an Umbraco content data source).
I wonder if there is a better way to configure the type of value you would to be returned from a Data List?
Describe the solution you’d like
Currently the IDataListSourceValueConverter
interface can be used on a data source to convert the value to a specific type. However this ties the data source and output object-type close together, which irks me a little. I’m wondering about the scenario where users could specify a different value type, e.g. for the Umbraco content data source, whether they would prefer to have the IPublishedContent
, or the Udi
, or the raw string of the UDI, or even the int
?
On the data type configuration, we could have a 3rd field for “Value converter”, with options on how to configure the desired output. The default option would still be a string
(and whether that’d be single or enumerable, depending on the list editor used).
I haven’t considered much on the technical implementation of this yet, I envisage an interface (much like the data source and list editor interfaces), e.g. IDataListValueConverter
, which would open it up to user customisation too.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (6 by maintainers)
Thanks @bjarnef. This is purely a prototype at the moment - nothing set in stone. 😃 Although in the case of converting values from the Umbraco Content data source, it’d only be
IPublishedContent
, asIPublishedElement
isn’t something that is query-able with Umbraco’s APIs, (yet). But if that day may come, it’d be totally possible to doIPublishedElement
too with this approach. 👍@leekelleher Just want to say that this looks utterly awesome Lee!
I’d have thunk this was a giant can of worms, to be honest 😄 - I was really just thinking of how the Color Picker can be configured to either just return the hexcolor, or to return an object (tuple?) with
.Color
and.Label
properties.This would be all sorts of cool!
/Chriztian