Copied to clipboard

Flag this post as spam?

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


  • Ludvig Flemmich 1 post 71 karma points
    1 week ago
    Ludvig Flemmich
    0

    Existing BlockList datatype - saving in Grid editor. V8.7

    I have created a DocumentType in Umbraco which is an element type. It has two properties - of the type BlockList with some properties, as well as a BlockType to put in it.

    Then I created a custom GridEditor that calls the editorService to create an instance of that BlockList to save into the grid.

    But to get it to work I have to specify a ParentId where the created instance will be saved - how can I make that parent the grid property on the page I am on?

    Here's my angular controller, which uses the documentTypeAlias of the BlockList I created in the CMS:

     $scope.open = function () {
        let editor = {
            create: true,
            documentTypeAlias: "services",
            allowSaveAndClose: true,
            allowSave: false,
            close: function () {
                editorService.close();
            },
            submit: function (response) {
                // Ugly workaround to temporarily make it work
                // Literally takes the data from the content created and maps it and adds it to $scope.control.value
                let data = response.contentNode.variants[0].tabs[0].properties;
                var value = mapData(data);
    
                $scope.control.value = value;
                editorService.close();
            },
            parentId: -1
        };
        editorService.contentEditor(editor);
    };
    

    I have tried setting the parentId to different types, like a row or area in the grid, but that results in an error stating that the parent was not found.

    Using the root id (-1) enables me to create the content, but it is created as a page in the tree even though it is configured as an element type.

    I also tried using the package DocType Grid Editor, but it hasn't been updated to enable the use of BlockList yet unfortunately.

Please Sign in or register to post replies

Write your reply to:

Draft