Copied to clipboard

Flag this post as spam?

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


  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Apr 27, 2015 @ 04:48
    Peter Gregory
    0

    Custom Tree Picker

    Hi all.

    So the requirement I have is to build create a tree picker that shows a tree of hierarchical data from a custom API.

    So far I have managed to create the tree and also to get it to load the picker using my custom tree using the DialogService and TreePicker dialog.

    However i have now hit a wall as when you pick the item it is automatically calling the entityservice to try and get the model object for the picked item. This is an issue because the item is not an Umbraco item but a custom item from our database.

    What I want to know is it possible to tell the treepicker NOT to call the entity service and return just the ID or is there a way to tell the treepicker to call my own service to my custom entity model.

    My call to the treepicker looks like this:

    $scope.openPicker = function () {
    
    
        var pickerConfig = {
            section: "ecom",
            treeAlias: "departmenttree",
            filter: null,
            maxNumber: null,
            minNumber: null,
            multiPicker: false,
            callback: function (data) {
                picked = data.id;
                if ($scope.control) {
                    $scope.control.value = data.id;
                } else {
                    $scope.model.value = data.id;
                }
                $scope.setPreview();
            }
        };
        var d = dialogService.treePicker(pickerConfig);
    };
    

    Every time you pick an item in the tree it it fires the the tree event for selection. This fires the nodeSelectHandler.

    $scope.dialogTreeEventHandler.bind("treeNodeSelect", nodeSelectHandler);
    

    Which tries to process the selected item to get the actual Umbraco entity by calling the entity service.

    I believe I can solve my problem by creating my own custom eventHandler and overriding the one that the tree uses by default allowing me to call my own service to get the info about the object.

    Is this even going to be possible? Will update all if I find a way to do it but if anyone has done this successfully I am all ears.

    Cheers Peter

  • Lee Howarth 3 posts 23 karma points
    Aug 20, 2015 @ 15:32
    Lee Howarth
    0

    Hi,

    Did you ever manage to get this to work? I am attempting to do something very similar at the moment but am also having issues with the tree picker. If so do you have any example code?

    Regards

  • christopher muya 18 posts 200 karma points
    Jan 03, 2019 @ 17:25
    christopher muya
    0

    Did you find a solution?

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Aug 22, 2015 @ 23:15
    Peter Gregory
    0

    Hey Lee

    I was a contractor on this project and have since moved on and no longer have the source. We did resolve it but we had to create our own version of the picker by copying the tree picker the umbraco source and modifying its behavior.

    Hopefully you get it resolved but if I come across the code again I will post it.

Please Sign in or register to post replies

Write your reply to:

Draft