Copied to clipboard

Flag this post as spam?

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


  • Nelson 94 posts 246 karma points
    Jan 12, 2016 @ 07:38
    Nelson
    0

    How to get the value from Approved Color

    Hi guys!

    I set up my own grid editor with LeBlender, and I want to add the Approved Color Datatype to it. I already added the colors of choice, but I'm not able to access its value from mypartial view. What I have in my partial template is the following:

    <div class="box" style="background-color:item.GetValue("backgroundColor")">
    

    How can I get the color code picked from the Approved Color?

    Many thanks!

  • Nelson 94 posts 246 karma points
    Jan 22, 2016 @ 01:51
    Nelson
    0

    Please help! I've been trying to find a solution for the past days but so far didnt found any! Would really appreciate some help on this!

    Thank you very much!

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Jan 22, 2016 @ 07:57
    Bjarne Fyrstenborg
    0

    Hi Nelson

    Have you tried with the following?

    <div class="box" style="background-color: #@item.GetPropertyValue("backgroundColor")">
    

    I think the Approved Color datatype returns the selected value without hex "#".

    /Bjarne

  • Nelson 94 posts 246 karma points
    Jan 22, 2016 @ 08:32
    Nelson
    0

    Thank you very much! That worked perfectly!!! And something so simple :) Perhaps you can give me an extra help with something else: I'm creating another grid editor, and one of the parameters is a link which I configured to be inputed as a text string. I'm using this format:

    <a href="@Umbraco.TypedContent(item.GetValue<string>("link") ).Url">
    

    but somehow I get this message: Object reference not set to an instance of an object.

    I've tried many ways to put this to work, but so far none worked out. Do I need to use any other property type (not text string)? I tried ti use Related Links, but it didnt work as well

    Thank you very much! Really appreciate your help!

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Jan 22, 2016 @ 09:24
    Bjarne Fyrstenborg
    0

    It is probably because item.GetValue

    Which datatype are you using for the link? If it is an internal link you can use Content Picker, which store a node id.

    First you should check that this return a value (in /App_Data/umbraco.config you should be able to find something like < link>1234< /link>

    @item.GetPropertyValue("link")
    

    as default it is of type string, so the same as

    @item.GetPropertyValue<string>("link")
    

    the latter specify the output type: https://our.umbraco.org/documentation/Reference/Templating/Mvc/views

    /Bjarne

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies