List of drop down values with id and sort order (v7.2.2)
Hello,
Just wanted to double check the correct way of getting the list of prevalues of a dropdown datatype. So far i have:
New way i think, i got this though looking at core code on github:
var dataService = ApplicationContext.Services.DataTypeService;
var dictionaryDropdownPreValues = dataService.GetPreValuesCollectionByDataTypeId(idOfProperty).PreValuesAsDictionary;
foreach(KeyValuePair<string, PreValue> preValue in dictionaryDropdownPreValues){
@:@preValue.Value.Id : @preValue.Value.Value : @preValue.Value.SortOrder
}
Old way from a stack overflow article:
var preValues = PreValues.GetPreValues(idOfProperty).Values;
var enumerator = preValues.GetEnumerator();
while (enumerator.MoveNext()){
var preValueText = ((umbraco.cms.businesslogic.datatype.PreValue)enumerator.Current);
@:@preValueText.Id : @preValueText.Value : @preValueText.SortOrder
}
Really old way (?deprecated):
var preValuesDropdown = uQuery.GetPreValues(idOfProperty);
foreach(var preValue in preValuesDropdown){
@:@preValue.Id : @preValue.Value : @preValue.SortOrder <br/>
}
Am i correct in assuming the first option (using the ApplicationContext.Services.DataTypeService) is the correct way of doing this?
To give some context, i am doing this because i want to make a few member drop down properties accessible on the member profile page.
List of drop down values with id and sort order (v7.2.2)
Hello,
Just wanted to double check the correct way of getting the list of prevalues of a dropdown datatype. So far i have:
New way i think, i got this though looking at core code on github:
Old way from a stack overflow article:
Really old way (?deprecated):
Am i correct in assuming the first option (using the ApplicationContext.Services.DataTypeService) is the correct way of doing this?
To give some context, i am doing this because i want to make a few member drop down properties accessible on the member profile page.
is working on a reply...