Custom List View that includes the my custom Dropdown List.
The list view however does not show the text values. It shows the key ID. I tried both DropdownlistPublishingKeys and Dropdownlist, they both show the ID, not the text.
If i understand your question correctly, then u went into the umbraco backoffice, and went to the developer section, and create a custom data type with a name and a property type of DropDownList and then added some prevalues as text. If that is the case then this code will do the trick, but in my example i am doing the code inside a controller and returning it as part of a model and then returning a PartialView with myModel values
XPathNodeIterator iterator = umbraco.library.GetPreValues(1125);
// 1125 is the ID of your custom datatype, you can see the ID of your
// custom datatype by going to it in the backend inside the developer tab
// and checking the URL
iterator.MoveNext(); //move to first
XPathNodeIterator preValues = iterator.Current.SelectChildren("preValue", "");
while (preValues.MoveNext())
{
string preValue = preValues.Current.Value;
int preValueId = preValues.CurrentPosition;
listBaneItems.Add(new SelectListItem
{
Text = preValue,
Value = preValue
});
myModel.ListeAfBaneOnsker = listBaneItems;
}
Thank you very much for the info. You are absolutely correct, I did go in the backoffice, created a custom dropdown (DropX) and put in some pre-value texts in there.
And then, I created a custom ListView (say ListX) in the backoffice again and added ListX in the list view.
I am not entirely sure where to put the code you sent though. I looked everywhere in the umbraco backoffice for controllers, I cant find any. I looked within the actual site files (the entire application) but I cant find anything in there either. Can you please put me in the right direction as to where I should be inserting this code? I assume a file that has the ListX code. Sorry I am quite new to this so my lingo and references might be off. Thanks for your help again. Appreciate it.
I've just come across the same problem. Really odd this isn't out the box, and even stranger the id's are the display default. Did you come up with a solution?
@Casper - Like MaryL I'm not sure where to put your code. Can you advise?
I just found a need for this too. Anyone have any ideas? Can we somehow cleanly tap into the rendering of the listview and replace the Ids with the text equivalent?
Instead of creating a custom listview property editor a temporary solution might be to add a custom listview layout and optionally order it as the first listview layout.
Display Dropdown Text in List View
I have:
The list view however does not show the text values. It shows the key ID. I tried both DropdownlistPublishingKeys and Dropdownlist, they both show the ID, not the text.
How do I change this?
If i understand your question correctly, then u went into the umbraco backoffice, and went to the developer section, and create a custom data type with a name and a property type of DropDownList and then added some prevalues as text. If that is the case then this code will do the trick, but in my example i am doing the code inside a controller and returning it as part of a model and then returning a PartialView with myModel values
Hi Casper,
Thank you very much for the info. You are absolutely correct, I did go in the backoffice, created a custom dropdown (DropX) and put in some pre-value texts in there.
And then, I created a custom ListView (say ListX) in the backoffice again and added ListX in the list view.
I am not entirely sure where to put the code you sent though. I looked everywhere in the umbraco backoffice for controllers, I cant find any. I looked within the actual site files (the entire application) but I cant find anything in there either. Can you please put me in the right direction as to where I should be inserting this code? I assume a file that has the ListX code. Sorry I am quite new to this so my lingo and references might be off. Thanks for your help again. Appreciate it.
Hey guys,
I've just come across the same problem. Really odd this isn't out the box, and even stranger the id's are the display default. Did you come up with a solution?
@Casper - Like MaryL I'm not sure where to put your code. Can you advise?
I just found a need for this too. Anyone have any ideas? Can we somehow cleanly tap into the rendering of the listview and replace the Ids with the text equivalent?
Thanks
Just found that this was raised as an issue by Jan Bengtsson in March 2015.
Dropdown list in List View - a switch is needed
So, I suggest you vote for it to show your interest.
Regards
Ver
Anyone know if there's an out-of-the-box solution for this?
I'd rather not have to code a custom listview just to display a dropdown value...
Same problem.
We need a solution.
It would indeed be useful to display the prevalue text instead of the prevalue id. http://issues.umbraco.org/issue/U4-6405
Instead of creating a custom listview property editor a temporary solution might be to add a custom listview layout and optionally order it as the first listview layout.
/Bjarne
Ok, thanks.
I follow the tutorial.
Replacing the string in the html file I have:
But this way I retrieve the ID of my drop down list item.
How can I get the text?
Thanks in advance
In the Angular controller, you can use that id and
entityResource
https://our.umbraco.org/apidocs/ui/#/api/umbraco.resources.entityResource to look-up the entity and get its name, when using MNTP.For dropdownlist you need to get the text from the prevalue id ... not sure if there is anything in the core for that in Angular, otherwise you can create an Angular service like this https://github.com/warrenbuckley/Analytics/blob/develop/Analytics/App_Plugins/Analytics/backOffice/AnalyticsTree/resources/Settings.Resource.js, which makes a http request to a web api method, which return the prevalue text. https://our.umbraco.org/documentation/reference/routing/webapi/
The ApiController can inherit from
UmbracoAuthorizedController
...Some other relevant resources:
https://github.com/umco/umbraco-nested-content/blob/develop/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.filters.js
https://github.com/kgiszewski/ArchetypeManual/blob/master/02%20-%20Configuration.md#label-template
is working on a reply...