Edit selected nodes in `contentPicker()`
# help-with-umbraco
g
I am creating a custom property editor, that has an option to select some content nodes as configuration of the property. I try to use
editorService.contentPicker
editor for that job. There are two issues with it: 1.
submit
function parameter contains
selected
array, but it always includes only the clicked item and not the whole selection, so I should keep track of actually selected items manually 2. there is no option to pass already selected nodes to the editor to be able to edit the selection https://apidocs.umbraco.com/v10/ui/#/api/umbraco.services.editorService Is there any other more suitable editor for that ?
Anyone?
s
@leekelleher any suggestions, you wizard king of property editors?
We tried to inject previously selected values via properties
selectedIds
,
value
, with both array of strings and string of joined ids separeated by
,
.
Copy code
var editor = {
      multipicker: true,
      startNodeId: startNodeUdi,
      value: selectedItems,
      selectedIds: selectedItems,
      submit: function (selected) {
        $scope.model.value[modelArrayName] = addOrRemoveItem($scope.model.value[modelArrayName], selected.selection[0].udi)
        populateVM(modelArrayName);
      },
      close: function () {
        populateVM(modelArrayName);
        editorService.close();
      }
    }
    editorService.contentPicker(editor);
I was looking into the code of
umbraco.controllers
, and I saw this line
$scope.model.selection = [];
on the beggining of the
Umbraco.Editors.TreePickerController
. It looks like there is no chance to set the selection from the outside. How does original umbaco editors work that they pass this info to the next editor?