Copied to clipboard

Flag this post as spam?

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


  • Nigel Wilson 945 posts 2077 karma points
    May 28, 2024 @ 20:57
    Nigel Wilson
    0

    Custom Section And Preselecting Umbraco Nodes When Opening Tree Picker

    Hi there

    Long shot given it's Version 8 but...

    • I have a custom section
    • I have a view for creating and editing data that is saved in a Custom Database.
    • One piece of data is a comma separated string of Umbraco Node Id's.
    • I have the tree picker working for selecting and saving the node Id's.
    • I cannot get the nodes to be preselected when editing an existing record.

    My code for the tree picker is

    $scope.OpenTree = function (index, evt) {
            dialogOptions = {
                view: "views/common/infiniteeditors/treepicker/treepicker.html",
                size: "small",
                section: "content",
                treeAlias: "content",
                dataTypeKey: 'id',
                multiPicker: true,
                submit: function (data) {
                    if (data.selection.length > 0) {
                        $scope.isLoading = true;
                        let selectedSKUNodeID = "";
                        let selectedSKUNodeName = "";
    
                        angular.forEach(data.selection, function (node, index) {
                            selectedSKUNodeID = selectedSKUNodeID === '' ? node.id : selectedSKUNodeID + "," + node.id;
                            selectedSKUNodeName = selectedSKUNodeName === '' ? node.name : selectedSKUNodeName + ", " + node.name;
                        });
                        $scope.promotion.SelectedSKUNodeNames = selectedSKUNodeName;
                        $scope.promotion.SelectedSKUNodeIDs = selectedSKUNodeID;
                    }
    
                    $scope.isLoading = false;
                    editorService.close();
                },
                close: function () {
                    editorService.close();
    
                },
                value: $scope.promotion.TreePickerNodes
            };
            editorService.contentPicker(dialogOptions);
        };
    

    For the value I have tried a simple comma separated list of ID's, I have tried creating an array of Umbraco objects (to mirror the structure of data.selection in the above code). Nothing has worked.

    Can anyone confirm how to get the tree to show the tick on the previously selected nodes when opening the Umbraco Content tree ?

    Thanks

    Nigel

Please Sign in or register to post replies

Write your reply to:

Draft