Copied to clipboard

Flag this post as spam?

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


  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 01, 2016 @ 07:29
    Sven Geusens
    0

    Custom grid editor using existing datatype editors.

    Greetings Umbracians,

    After 4+ months of learning umbraco on the job, I have finally stumbled onto something neither the forum, the docs or my boss have a (partial) answer to.

    I want to make a grid editor and set out with a simple enough design. A text box and a dropdown with a color.

    Now i want to change the textarea i have by an existing RTE and the select by a color picker.

    If any of you could point me in the direction of a tutorial i might have missed or help me understand how it all works, I would really appreciate it.

    Below is what i currently have.

    All the code currently resides in Solution\WebProject\app_plugins\GridManuals

    Package.manifest

    {
    "gridEditors": [
        {
            "name": "Action",
            "alias": "GridManuals.Action",
            "view": "/app_plugins/GridManuals/ActionEditor.html",
            "render": "/app_plugins/GridManuals/ActionRender.cshtml",
            "icon": "icon-code",
            "config": {
                "color": "red",
                "text-align": "right"
                }
        }
    ],
    javascript:[
        "/app_plugins/GridManuals/Action.Controller.js"
    ]
    

    }

    Super basic controller (action.Controller.js)

    angular.module("umbraco").controller("GridManuals.ActionEditorController", function ($scope) {
    //Nothing yet
    

    });

    Editor (ActionEditor.html)

    <div ng-controller="GridManuals.ActionEditorController">
    <textarea rows="1" ng-model="control.action"></textarea>
    <select ng-model="control.color">
        <option value="#ff0000" style="color:#ff0000; Background:#ff0000">Red</option>
        <option value="#ff8000" style="color:#ff8000; Background:#ff8000">Orange</option>
        <option value="#ffff00" style="color:#ffff00; Background:#ffff00">Yellow</option>
        <option value="#00ff00" style="color:#00ff00; Background:#00ff00">Green</option>
        <option value="#00ffff" style="color:#00ffff; Background:#00ffff">Teal</option>
        <option value="#0000ff" style="color:#0000ff; Background:#0000ff">Blue</option>
        <option value="#bf00ff" style="color:#bf00ff; Background:#bf00ff">Purple</option>
        <option value="#ff00bf" style="color:#ff00bf; Background:#ff00bf">Pink</option>
    </select>
    

  • Ian 178 posts 752 karma points
    Aug 01, 2016 @ 09:06
    Ian
    0

    Depends if you really really want to create your own property editor, or go for the MUCH easier route of using doctype grid editor or leblender where you could do what you want without any backoffice code.

  • David Peck 690 posts 1896 karma points c-trib
    Aug 01, 2016 @ 09:25
    David Peck
    0

    Ian is correct. Those two packages are the simple solution. If you do want to go down the alternative route then the colour picker you'll probably need to break out some Angular skills for.

    The RTE is a bit simpler, just replace your textarea with this:

    <div grid-rte
        configuration="model.config.rte"
        value="control.action"
        unique-id="control.$uniqueId">
    </div>
    
  • Sven Geusens 169 posts 881 karma points c-trib
    Aug 01, 2016 @ 10:04
    Sven Geusens
    0

    Seems simple enough, is there a list somewhere that shows this kind of code for other standard umbraco editors?

    I might eventually use one of the 2 packages but it's always nice to understand how things work.

    Since umbraco already has some easy reusable code available like the snippet you posted above it would be a shame not to use it right? Especially since the only reason why would be: the documentation is lacking and there is a package that creates these things for you...

  • David Peck 690 posts 1896 karma points c-trib
    Aug 01, 2016 @ 12:17
    David Peck
    0

    Yes and no. It's here: https://our.umbraco.org/apidocs/ui/#/api

    But it's old and out of date as best I can tell.

Please Sign in or register to post replies

Write your reply to:

Draft