0

I'm struggling with this issue for a couple of days now, can you help me figure it out?

I'm trying to set the selected items for the component but it just let me set the initial selected items, but I need to set it after it is created. I wish it had a property like 'SelectedValues' where I could pass an array..instead it has a callback function but I can only retrieve what the user selected not set the selection.

the documentation https://pnp.github.io/sp-dev-fx-controls-react/controls/ComboBoxListItemPicker/ isn't saying anything about how to do it, just to retrieve what the user chose.

The code is like this:

<ComboBoxListItemPicker listId='da8daf15-d84f-4ab1-9800-7568f82fed3f'
                        columnInternalName='Title'
                        keyColumnInternalName='Id'
                        filter="Title eq 'SPFx'"
                        defaultSelectedItems=[{Id: 2, Title:"Test"}]
                        onSelectedItem={this.onSelectedItem}
                        webUrl={this.context.pageContext.web.absoluteUrl}
                        spHttpClient={this.context.spHttpClient} />

The onSelectedItem change event returns the list items selected and can be implemented as follows:

private onSelectedItem(items: []) {
    console.log("selected items:", items);
}
Amos
  • 2,030
  • 1
  • 5
  • 9
André Matos
  • 35
  • 1
  • 6

1 Answers1

0

I managed to solve this by using a workaround...I force the component to be recreated by setting a new key to the component after I update the state with the values I want selected, so i just use the property initialselectedvalues.

André Matos
  • 35
  • 1
  • 6