Copied to clipboard

Flag this post as spam?

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


  • Marianne Larsen 22 posts 94 karma points
    Jan 08, 2017 @ 09:53
    Marianne Larsen
    0

    Custom contentpicker - multipicker not allowing picking multiple items

    I'm trying to create a custom contentpicker to use in grid, where it would be nice to make it possible to pick multiple items.

    So far i've been able to add and store one item at a time to the contentpicker and my code is like this.

    controllers.js

    angular.module("umbraco")
    .controller("Umbraco.SNCPPropertyEditors.Grid.ContentController",
    function ($scope, $timeout, dialogService, contentResource) {
    
    
        $scope.setContentId = function () {
    
            dialogService.contentPicker({
                multiPicker: false,
                callback: function (data) {
                    $scope.control.value = {
                        id: data.id,
                        name: data.name,
                    };
                    $scope.setPreview();
                }
            });
        };
    
        $scope.setPreview = function () {
    
            if ($scope.control.value.id) {
                $scope.id = $scope.control.value.id;
                $scope.name = $scope.control.value.name;
            }
        };
    
        $timeout(function () {
            if ($scope.control.$initializing) {
                $scope.setContentId();
            } else {
                $scope.setPreview();
            }
        }, 200);
    });
    

    I've tried to set multipicker to true and add a foreach to store data for each item, but then the dialogservice don't show the "select".

    An other question i have is this: How can i store other data than id/name from my picked content - eg. image url to use in the grid preview?

    Any hints/tips are welcome :)

Please Sign in or register to post replies

Write your reply to:

Draft