Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michelle Topp 33 posts 143 karma points
    Apr 20, 2016 @ 13:38
    Michelle Topp
    0

    DropDownList Is not showing Value

    Hi,

    I'm currently working with a load of models and have set up a data type of type Umbraco.DropDown. When working within Umbraco the values are passed without any issue. (I'm using Ditto for strongly type models) But when trying to get the info via extended product content the value for the dropdownlist is coming through as a number. I've even tried applying a custom ditto provider to pass the value of the drop downlist. But on debugging the info saved in the database for this value is actually a number(int) and not the typed value. Is this an issue with the way Merchello saves extended content?

    Any help is greatly received. enter image description here

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 10, 2016 @ 20:24
    Rusty Swayne
    0

    I'm guessing you are actually saving the reference to the property (Id) Ditto uses to build the property value.

    What you probably want to do is to serialize the object - before adding it to the extended data collection.

    Something like

     // Assuming the type of the ditto object is a newable class
      var myObj = JsonConvert.Serialize(dittoObject);
    

    Can you post the code you are using to add your value to the ExtendedDataCollection?

  • Michelle Topp 33 posts 143 karma points
    May 11, 2016 @ 09:32
    Michelle Topp
    0

    Hi Rusty,

    I've extended the ProductContentModel within the Bazaar library as follows:

     public class ProductContentModel
    {      
        public string AltTitle { get; set; }
    
        public string Description { get; set; }
    
        public HtmlString About { get; set; }        
    
        public string InstructionFile { get; set; }
    
        public HtmlString Delivery { get; set; }
    
        public string ExtraContentTitle { get; set; }
    
        public HtmlString ExtraContent { get; set; }
    
        public string CartWarning { get; set; }
    
        public string ProductType { get; set; }
    
        [DittoValueResolver(typeof(CustomResolvers.BoxColourResolver))]
        public string BoxColour { get; set; }
    
        [TypeConverter(typeof(DittoPickerConverter))]
        public IEnumerable<FAQModel> FAQs { get; set; }
    
    }
    

    Then on the ProductCollection.cshtml I've got this

      @foreach (var product in page.Products)
                    {
                        var prod = product.As<ProductContentModel>();
    
                        var boxc = ContentHelper.BoxColour(prod.BoxColour);
    

    And because I needed it to work I put in a temp fix to bodge it which basically manually checks the number and puts in the right string, as the resolves still brings through a number.

    Resolver code below:

    public class BoxColourResolver : DittoValueResolver
        {
            public override object ResolveValue()
            {
                var colour = Content.GetProperty("boxColour").Value;
    
                if (String.IsNullOrEmpty(colour.ToString()))
                    colour = "purple"; //default
    
                return colour;
            }
        }
    
        public class BoxSizeResolver : DittoValueResolver
        {
            public override object ResolveValue()
            {
                return Content.GetProperty("BoxSize").Value;
            }
        }
    

    As I've said the datatype is just a standard dropdown list within umbraco and works fine on the main view pages. It's just via products it's not pulling the data. Anything you can suggest to make this cleaner would be much appreciated!

    regards, Michelle

    enter image description here

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 12, 2016 @ 14:02
    Rusty Swayne
    0

    Hey MIchelle,

    It may be that there is a problem with the drop down list serialization when we save it to a detached content value in the 1.14.1 version. I've done quite a lot of work in 2.0.0 to fix up some of the reported data type inconsistencies.

    I'll test the drop down list to make verify it works in 2.0.0 (without Ditto) today. If it was broken in 1.14.1 and is fixed in 2.0.0, it may just start working with Ditto. If after the update, it still does not work, we'll have to start looking at how Ditto is handling the value ... I have used Ditto quite a bit and can't think of a reason off the top of my head why it would not work.

  • Michelle Topp 33 posts 143 karma points
    May 12, 2016 @ 14:42
    Michelle Topp
    0

    Hi Rusty,

    Okay, thanks. Any news when the update will be available? I saw somewhere it was imminent.

    Michelle

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    May 12, 2016 @ 19:19
    Rusty Swayne
    0

    Hey Michelle,

    I'm hoping to push it tomorrow but am still testing to make sure things are good to go ... so latest Tu. of next week.

  • Michelle Topp 33 posts 143 karma points
    Jun 27, 2016 @ 14:30
    Michelle Topp
    0

    Hi Rusty,

    I've upgraded to umbraco 7.4.3 and have installed merchello 2.0.1. This issue is still happening, I'm having to build support switch statements to get the correct values through.

    regards, Michelle

Please Sign in or register to post replies

Write your reply to:

Draft