WjMultiSelect, SelectedValuePath not working?

Posted by: rob.webb on 1 September 2021, 8:18 am EST

    • Post Options:
    • Link

    Posted 1 September 2021, 8:18 am EST

    I am trying to use the WjMultiSelect to send up an array of ints to an API. However, even with a SelectedValuePath set to ‘id’ it puts the whole object in the property. So I have an array of the object instead of an array of ints.

    Is there a solution to this?

    
      <wj-multi-select
        #multiSelect
        class="form-control form-control-sm"
        formControlName="ids"
        [id]="controlDirective.name"
        [hidden]="isLoading"
        [ngClass]="validationCss"
        [isRequired]="false"
        (initialized)="onInitialized()"
        [displayMemberPath]="'display'"
        [selectedValuePath]="'id'"
      ></wj-multi-select>
    
    
  • Posted 2 September 2021, 5:26 am EST

    Hello,

    Sorry, but we are unable to replicate the issue at our end. The selectedValuePath is used to Gets or sets the name of the property used to get the selectedValue from the selectedItem, if you are getting object([object][object]) in the multiSelect items then make sure you provide correct displayMemberPath to the multiSelect.

    I have created a sample for the same, please refer to the sample and feel free to modify the sample to replicate the issue and send us back so that we can help you better.

    sample link: https://stackblitz.com/edit/angular-thp2ft?file=src%2Fapp%2Fapp.component.ts

    Regards

  • Posted 2 September 2021, 5:56 am EST

    If there are multiple ‘values’ selected, is it not possible for the SelectedValue to be [1,2,3] (if 3 items are selected) therefore skipping the need to map to get the desired values. E.g. (checkedItems.map(m => m.id))

    It does not really make sense that theres only ‘1’ selected valuewhen it is a ‘multi’ select.

  • Posted 3 September 2021, 8:04 am EST

    Hello,

    We apologize, but this is the default behavior of multiSelect. SelectedValue property only gets the selected value(item with the selection) not the array of the selected items. The only possible solution is to get the desired mapped data from the array of checkedItems as you explained in the above response.

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels