Copied to clipboard

Flag this post as spam?

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


  • umbraco7newbie 2 posts 72 karma points
    Jan 19, 2020 @ 18:30
    umbraco7newbie
    0

    Getting back array items from property editor to grid property editor

    Hi,

    I have created a property editor named textboxWithIcon where a user can add an icon and textbox item (multiple items to grid)

    Now on creation of grid property which has the textboxWithIcon property editor.

    Grid property editor html

    <umb-editor model="control.textWithIcon"/>
    

    The actual property editor controller

    umbraco.controller('Editors.TextBlockWithIconController', function ($scope, dialogService) {
            if (!$scope.items) {
                $scope.items = [];
            }
            $scope.addItem = function () {
                let item = {};
                $scope.items.push(item);
            }
            $scope.removeItem = function (index) {
    
            }
    
            $scope.setImage = function (key) {
                dialogService.mediaPicker({
                    callback: function (data) {
                        $scope.items[key] = {
                            image: data.image
                        };
                    }
                });
            };
        });
    

    The grid property editor controller

    umbraco.controller('Editors.CompositeTextBlockWithIconController', function ($scope) {
                if (!$scope.control) {
                    $scope.control = {};
                    $scope.control.items = [];
                }
    
                if (!$scope.control.textWithIcon) {
    
                    $scope.control.textWithIcon = {
                        alias: 'textWithIcon',
                        label: 'iconWithText',
                        description: 'Icon with text',
                        view: '/App_Plugins/textBlockWithIcon.html'
                    };
                }
    
    
                $scope.$watch('control.textWithIcon.value', function (newValue) {
                    alert("undefined is shown here");
                });
    
            });
    

    I am able to pick image and text in backend but on save it becomes empty and doesn't seem to persist.

    The idea is to get back list of items (from the property editor to the grid ) and show it, which is essentially an array of images and corresponding text back into the grid control.

    --umbraco 7 newbie

Please Sign in or register to post replies

Write your reply to:

Draft