Copied to clipboard

Flag this post as spam?

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


  • Jamie Pollock 174 posts 853 karma points c-trib
    Oct 07, 2014 @ 14:55
    Jamie Pollock
    0

    Umbraco v7 - dialogService.treePicker with a custom tree

    Hi folks,
    I'm using the dialogService.treePicker with a custom content section & tree (based around the blog post on nibble) I've built in Umbraco v7.1.7.

    The tree itself extends from TreeController. The dialog itself displays the tree perfectly. However when I get the data back from the callback it's an empty array, if using treePicker multiPicker: true.

    Similarly if I were to put treePicker as multiPicker: false. I get a 404 from the following call:

    /umbraco/backoffice/UmbracoApi/Entity/GetById?id=<id of my item>&type=Document
    

    Obviously because there is no Document with that node.

    Does anyone know how to use the dialogService.treePicker with custom content? Right now it seems the treePicker is only intended to work with UmbracoEntitys (eg. Document, Media, etc).

    Thanks,
    Jamie

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Oct 08, 2014 @ 13:17
    Warren Buckley
    0

    HI Jamie,
    I just skimmed the source code as well and the treepicker if you configure to multiPicker true it has the button that calls a ng-click method called multiSubmit that tries to get the selected items by using the entityResource to try and fetch the content/media/member.

    https://github.com/umbraco/Umbraco-CMS/blob/release-7.1.7/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.html#L61
    https://github.com/umbraco/Umbraco-CMS/blob/release-7.1.7/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js#L130

    I would recommend you build your own custom dialog for picking item/s from your own tree. You can base it heavily off the source of what the core team is doing, but pass back a simple JSON object you want as opposed to using the entityResource to go and fetch it from Umbraco.

    There is the custom directive for loading a tree in your custom HTML dialog, where you pass in the section, treeAlias and so on:
    https://github.com/umbraco/Umbraco-CMS/blob/release-7.1.7/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.html#L37

    So you can by studying a little of the source code come up with your own tree dialog, that passes the JSON item/s you want back to your main editor/controller once the item/s have been selected from the dialog.

    Hope this helps & let me know how you get on.

    Cheers
    Warren

  • Jamie Pollock 174 posts 853 karma points c-trib
    Oct 08, 2014 @ 14:00
    Jamie Pollock
    0

    Hey Warren,
    I've actually done just that. :)

    It's not a tree but it does leverage the umb-editor checkboxlist. I'm thinking about getting something up on github next week.

    Thanks for looking into this for me though.

    Thanks,
    Jamie

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Oct 08, 2014 @ 14:03
    Warren Buckley
    0

    Hi Jamie,
    What are you trying to achieve in your dialog as there may be a nice & simple way to do it?

    Cheers,
    Warren

  • Jamie Pollock 174 posts 853 karma points c-trib
    Oct 08, 2014 @ 14:07
    Jamie Pollock
    0

    Hey Warren,
    I've basically got a custom section which has a bunch of petapoco objects in it. Much like Tim's person section demo.

    Then another section wants to be able to pick from those objects and get their ids in a CSV which is then stored in the petapoco object as a property in the DB.

    If it weren't for the requirement this is all going on in a custom section then I'd just use nuPickers. However I thought it would be a nice user experience for the user if it opened in a dialog.

    Thanks,
    Jamie

  • Ben McKean 272 posts 549 karma points
    Mar 09, 2016 @ 10:55
    Ben McKean
    0

    I'm actually trying to do this for a users (not member picker). The dialogue appears on the right handside correctly but after selecting any nodes, the array returned is always empty.

    Could you please share any code that you did to fix this in the end?

Please Sign in or register to post replies

Write your reply to:

Draft