Copied to clipboard

Flag this post as spam?

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


  • Neil Chapman 42 posts 169 karma points
    May 01, 2019 @ 12:00
    Neil Chapman
    0

    Custom grid editor populated by existing Data Type

    Hi guys,

    I am creating a custom Grid Editor to display a dropdown list with a list of colours. I have hard coded the list of options and it all works fine.

    I have a Data Type that stores the list of colours available that is used elsewhere in Umbraco and it would be nice to get the list of options from the same source.

    Is it possible to populate the list of options in the dropdown from an existing Data Type, and how would I go about this? Do I need to hook into the DataTypeService somehow?

    My editor:

    <div ng-controller="myController">
        <select name="colour"
                class="umb-property-editor umb-dropdown"
                ng-model="control.Colour"
                ng-required="true">
          <option ng-repeat="x in colourOptions" value="{{x.value}}">{{x.text}}</option>
        </select>
    </div>
    

    My controller:

    angular.module("umbraco").controller("myController", function ($scope) {
      $scope.colourOptions = [
        {
          "text": "Red",
          "value": "red"
        }, {
          "text": "Blue",
          "value": "blue"
        }
        , {
          "text": "Green",
          "value": "green"
        }];
    });
    

    I've scoured the documentation and internet but can't seem to find what i'm looking for.

    Any help would be greatly appreciated!

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft