pnp / sp-dev-fx-controls-react

Reusable React controls for SPFx solutions
https://pnp.github.io/sp-dev-fx-controls-react/
MIT License
385 stars 379 forks source link

An example of ComboBoxListItemPicker with object passed into defaultSelectedItems? #1469

Closed sambilfinger closed 1 year ago

sambilfinger commented 1 year ago

Category

[ ] Enhancement

[ ] Bug

[x] Question

Version

Please specify what version of the library you are using: [3.12]

Question

I am trying to pass an object to the defaultSelectedItems of the ComboBoxListItemPicker but I am getting the error that ts cannot find the name of my column that I'm referencing. Giving me the error on the SoftwareFull part - cannot find name. Could someone give an example of a working bit of code?

<ComboBoxListItemPicker
        listId="..."
        columnInternalName="SoftwareFull"
        filter="Archived ne 1"
        keyColumnInternalName="Id"
        onSelectedItem={onSelectedSoftware}
        webUrl={props.context.pageContext.web.absoluteUrl}
        spHttpClient={props.context.spHttpClient}
        multiSelect={true}
        label="Software Required"
        disabled={disabled}
        // defaultSelectedItems={[2]}
        defaultSelectedItems=[{SoftwareFull: "test"}]
      />

I'm not really sure if I need to make an interface for the column or I have the wrong syntax etc.

Docs -> https://pnp.github.io/sp-dev-fx-controls-react/controls/ComboBoxListItemPicker/#implementation

Thanks!

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

sambilfinger commented 1 year ago

You need to pass the Id as well from what I can tell? And also need {} around the array, maybe the docs need updating?

defaultSelectedItems={[
          {
            Title: "Adobe Acrobat PDF Editor",
            Id: 1,
          },
        ]}