I have a Data-Type 'My Colors' that is based on the Umbraco Color Picker property editor.
I want to be able to fetch the current list of colors from the Data-Type, so I can perform some comparison tests with another value I have, and take appropriate actions.
How to drill-down into the Data-Type and fetch the values for this is totally eluding me at the moment.
I'd gotten part-way there with using the same reference to the current DataTypeService, but there is no GetDataType(name) function I can see, and GetDataTypeDefinitionByName(String) does not seem to provide me with a Configuration property.
However, that made me stop and think about what I was trying to do, and with a bit more API sleuthing, I decided that what I needed for this case is perhaps something along these lines:
var dataTypeService = ApplicationContext.Current.Services.DataTypeService;
var dataType = dataTypeService.GetDataTypeDefinitionByName("My Colors");
var dataTypeId = dataType.Id;
var dataTypePreValues = dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId).PreValuesAsDictionary;
Anyways... at the moment I seem to have a dictionary of values, which should keep my busy for a while.
Fetch color-values for data-type based on Umbraco Color Picker?
I have a Data-Type 'My Colors' that is based on the Umbraco Color Picker property editor.
I want to be able to fetch the current list of colors from the Data-Type, so I can perform some comparison tests with another value I have, and take appropriate actions.
How to drill-down into the Data-Type and fetch the values for this is totally eluding me at the moment.
You need to use the DataTypeService for that:
Then you can easily get your color picker by using:
And in that you should have a configuration property with a list of your colors in a json format.
Thanks for that.
I'd gotten part-way there with using the same reference to the current DataTypeService, but there is no GetDataType(name) function I can see, and GetDataTypeDefinitionByName(String) does not seem to provide me with a Configuration property.
However, that made me stop and think about what I was trying to do, and with a bit more API sleuthing, I decided that what I needed for this case is perhaps something along these lines:
Anyways... at the moment I seem to have a dictionary of values, which should keep my busy for a while.
is working on a reply...