Skip to content

sui-multiselect, how to preselect some options in case of multi-select from remote lookup  #333

@deepakgonda

Description

@deepakgonda

Bug description:

I am making multiple select using sui-multiselect but since the options list are too heavy (more than 65000 results), I decided to use remote lookup options. All is working fine in case of search and select one option from the list. But I don't get how to preselect some options while initializing the form. Or on some other action on some other element.

Code:

component.html

 <sui-multi-select class="selection" [placeholder]="'Select Organisations' 
   [(ngModel)]="registration.allowed_organisations.organisations" 
   [optionsLookup]="organisationsLookup"
   [labelField]="'name'" [isSearchable]="true" [maxSelected]="100"  #multiSelect>
 <sui-select-option *ngFor="let option of multiSelect.filteredOptions" [value]="option">
 </sui-select-option>
</sui-multi-select>

component.ts

public organisationsLookup = async (query: string) => {
    console.log("Org. QR: " + query);
    if (query) {
      const pr = new Promise<string>(resolve => {
        this.opportunityService.getAutoComplete(query, "Organisation").subscribe(
          data => {
            const organisations = data.data;
            resolve(organisations);
          }
        );
      });
      return pr;
    } else {
      return [];
    }
  };

Version of Angular, ng2-semantic-ui, and Semantic UI:

Angular: 4.4.3

ng2-semantic-ui: 0.9.6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions