Finding only the DropDown prevalues that are being used
Hi,
What is the best way to get only the DropDown prevalues that are currently being used/have dependencies?
For example:
With a given list of Document Categories
The following code gets all the Document Categories:
var categories = DataTypeService.GetDataType(DropDownListIds.DocumentCategories)?.Configuration as DropDownFlexibleConfiguration;
Is there a way to only retrieve the prevalues that are being used (e.g. if there are no 'Policies' documents there is no point in displaying the option in the dropdown)?
Hi, I'm not 100% sure if you are simply trying to find the selected values in a dropdown or if you are creating a service that looks for all the uses of this property globally within a solution.
If you are only looking for the selected values in a view, it should be as simple as referring to the documentation
var selectedValues = Model.Value<IEnumerable<string>>("DropDown");
Hi Daniel,
Thank you for your reply.
It is the latter situation that I had in mind. Is there a 'out of the box' way to create a service that finds all the uses of this property globally within a solution?
Finding only the DropDown prevalues that are being used
Hi, What is the best way to get only the DropDown prevalues that are currently being used/have dependencies?
For example: With a given list of Document Categories
The following code gets all the Document Categories:
Is there a way to only retrieve the prevalues that are being used (e.g. if there are no 'Policies' documents there is no point in displaying the option in the dropdown)?
Thanks in advance
Hi, I'm not 100% sure if you are simply trying to find the selected values in a dropdown or if you are creating a service that looks for all the uses of this property globally within a solution.
If you are only looking for the selected values in a view, it should be as simple as referring to the documentation
Hi Daniel, Thank you for your reply. It is the latter situation that I had in mind. Is there a 'out of the box' way to create a service that finds all the uses of this property globally within a solution?
Hi again.
Don't know if there is a service for it, but I found it using some database queries.
Assuming that you use Umbraco 11, you could use this:
Use the returned Id from this list that matches your property editor: (296 is a dummy number)
That should get you all the data of where the property editor is used.
Hope it helps you create your service :)
thanks, I'll give it a try
is working on a reply...