Copied to clipboard

Flag this post as spam?

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


  • Shola 65 posts 273 karma points
    Jul 01, 2015 @ 15:38
    Shola
    3

    TIP: user-friendly labels for prevalues in grid settings/styles

    In the grid's documentation, it shows that prevalues can only be expressed as a simple array of strings: https://our.umbraco.org/Documentation/Getting-Started/Data/Content-Entry/Grid-Layout

    This means that while editing content, the programmatic value of your setting is also used as the label for itself. If you have prevalues that may not be very user-friendly (like css class names etc. that cannot have spaces or punctuation) this situation is not optimal.

    So instead, I figured out a way to have a user-friendly label separate from the actual prevalue. The following example uses a modified version of the radiobuttonlist called "friendlyradiobuttonlist."

    • Paste the following code in /App_Plugins/FriendlyGrid/prevalueeditors/friendlyradiobuttonlist.html

    http://codepen.io/anon/pen/pJaNab (look at HTML box)

    You'll notice it looks very similar to its counterpart in /Umbraco/Views/prevalueeditors/radiobuttonlist.html

    • Then whenever you create a setting that has a prevalue list, do something like the following. Notice the prevalues array is not of strings, but of objects with "label" and "value" properties:

    http://codepen.io/anon/pen/pJaNab (look at JS box)

  • Marcin Zajkowski 112 posts 585 karma points MVP 6x c-trib
    Jun 11, 2016 @ 22:58
    Marcin Zajkowski
    0

    Exactly what I was looking for. #h5yr!

Please Sign in or register to post replies

Write your reply to:

Draft