React MultiSelect - how to get selected items

2 posts, 0 answers
  1. Kara
    Kara avatar
    3 posts
    Member since:
    Sep 2017

    Posted 16 Nov Link to this post

    So all the examples given are for jQuery and show to use the id assigned to the select and use dataItems() to get the selected items in an array. However, for React, I haven't had luck defining a MultiSelect with an id, and I am unsure how to select a specific one to get the selected items. I have several multiselects defined and need to get the selected items that are provided via a remote data source. 

    Here is an example of one them: 

    <MultiSelect id="materials" dataSource = {this.materialOptions} dataTextField={'material_code'} dataValueField={'material_code'} placeholder='Select Materials...'/>

     

    When I view the element it doesn't have the assigned id "materials". So how I can access this outside of the render definition?

  2. Kara
    Kara avatar
    3 posts
    Member since:
    Sep 2017

    Posted 17 Nov in reply to Kara Link to this post

    Never mind. I figured it out. For those that may have a similar question what I did was separate my multiselects out into their own files and gave them getSelected() methods and used refs to give them handles that I could then call from the parent file. Worked like a charm. This is a good reference: https://stackoverflow.com/questions/37949981/call-child-method-from-parent
Back to Top