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).
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.
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.
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.
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.
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?
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:
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
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
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
Hi Jamie,
What are you trying to achieve in your dialog as there may be a nice & simple way to do it?
Cheers,
Warren
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
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?
is working on a reply...