Copied to clipboard

Flag this post as spam?

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


  • Leon 101 posts 489 karma points
    Mar 13, 2015 @ 01:34
    Leon
    0

    umbraco 7 data types grid settings view boolean

    Hello.

    How do I use the boolean view in the gridview settings?

    I want to apply a css class based on whether the user selects true or false. Do I need to use prevalues? Another option would be to use a radiobuttonlist, but boolean is better fitting to my logic.

    My Code - the json for the settings:

    [{
    "label": "Image Magnifier",
    "description": "Magnify the image on click or hover",
    "key": "class",
    "view": "boolean"
    

    }]

    My css class (sass)

    .imgMagnifier {
    
    }
    &:hover {
        position: absolute;
        border: 1px solid;
        width: 900px;
    }
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 13, 2015 @ 08:57
    Dennis Aaen
    100

    Hi Leon,

    I think what is going wrong here is that when you are using the boolean view, then your class would be set to 0 or 1 depening on if the checkbox is checked or not. So for your case I think you need to use a radiobutton list or a simple textstring where the user  can type in the class name. I think the radiobutton list is the most user friendly.

    So the JSON for this it looks likes

    [
      {
        "label": "Image Magnifier",
        "description": "Set a class on this element",
        "key": "class",
        "view": "radiobuttonlist",
        "prevalues": [
          "imgMagnifier",
          "none"
        ]
      }
    ]

    If you want to use the boolean view perhaps it could be a solution to prefix the chekbox using the modifier, so you classes would be something like this if it´s checked. .imageMagnifier-1 and if it not checked the it will get the class of .imageMagnifier-0

    "modifier": "imageMagnifier-{0}"

    You can also specify if you want the class to be on the row or the cell, if you do nothing the default is on both. You can find the documentation here: https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/Grid-Layout#Settingsandstyling

    On the Umbraco TV you will also find a video chapter about working with the grid layout http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/grid-layouts and there is a specfic video about how to work with setting and styles. http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/grid-layouts/settings-and-styles/

    Hope this helps,

    /Dennis

  • Leon 101 posts 489 karma points
    Mar 13, 2015 @ 10:23
    Leon
    0

    Thanks Denis.

    That's perfect. I'm using the boolean with the modifier and it's working great.

    Leon

Please Sign in or register to post replies

Write your reply to:

Draft