Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

multi select + search + Multiselect and Search in angular 13

  <mat-form-field style="display:none;">
                <mat-label>Select Dealer</mat-label>
                <mat-select [formControl]="dealerIdForSpas" multiple disableOptionCentering
                  [disabled]="LineItemsWithLoadTypeList.length==0">
                  <mat-option *ngFor="let item of DealersLookUpDataList" [value]="item.company"
                    (onSelectionChange)="filterPartsLoad()">
                    {{item.company}}
                  </mat-option>
                </mat-select>
              </mat-form-field> 

              <mat-form-field appearance="fill">
                <mat-label>Select Dealer</mat-label>
                <input type="text" id="searchDealer" #dealerSpas autocomplete="off" aria-label="Number"
                  placeholder="Select Dealer" matInput [formControl]="dealerIdForSpas"
                  [matAutocomplete]="autodealerIdForSpas">
                <mat-autocomplete #autodealerIdForSpas="matAutocomplete">
                  <mat-option *ngFor="let option of dealerfilteredOptionsForSpa | async" [value]="option.company"
                    (click)="selectdealerIdForSpas(option)" multiple>
                    {{option.company}}
                  </mat-option>
                </mat-autocomplete>
              </mat-form-field> 

              <!-- [(ngModel)]="selectedItems" -->
              <div class="col-md-9" style="background-color: white;">
                <ng-multiselect-dropdown [placeholder]="'Select Dealer'" [settings]="dropdownSettings"
                  [data]="dropdownList" [formControl]="dealerIdForSpas" (onSelect)="onItemSelect($event)"
                  (onSelectAll)="onSelectAll($event)">
                </ng-multiselect-dropdown>
              </div>


  dealerfilteredOptions: Observable<any[]>;
  dealerfilteredOptionsForSpa: Observable<any[]>;
  public AllCarrierDataList: any[] = [];
  public options: any[] = [];

  this.dealerfilteredOptions = this.dealerId.valueChanges
      .pipe(
        startWith(''),
        debounceTime(200),
        distinctUntilChanged(),
        map(valueGot => {
          debugger
          this.options = this._filterDealersList(valueGot);
          if (this.options !== undefined) {
            return this.options.slice(0, 40);
          }
        })
      );

    this.dropdownSettings = {
      singleSelection: false,
      defaultOpen: false,
      idField: 'dealerid',
      textField: 'company',
      selectAllText: 'Select All',
      unSelectAllText: 'UnSelect All',
      itemsShowLimit: 99999,
      allowSearchFilter: true
    };
Comment

Multiselect and Search in angular 13

npm install ng-multiselect-dropdown

import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';
// ...

@NgModule({
  imports: [
    NgMultiSelectDropDownModule.forRoot()
    // ...
  ]
  // ...
})
export class AppModule {}


...........................................
import { Component, OnInit } from '@angular/core';
import { IDropdownSettings } from 'ng-multiselect-dropdown';

export class AppComponent implements OnInit {
  dropdownList = [];
  selectedItems = [];
  dropdownSettings = {};
  ngOnInit() {
    this.dropdownList = [
      { item_id: 1, item_text: 'Mumbai' },
      { item_id: 2, item_text: 'Bangaluru' },
      { item_id: 3, item_text: 'Pune' },
      { item_id: 4, item_text: 'Navsari' },
      { item_id: 5, item_text: 'New Delhi' }
    ];
    this.selectedItems = [
      { item_id: 3, item_text: 'Pune' },
      { item_id: 4, item_text: 'Navsari' }
    ];
    this.dropdownSettings = {
      singleSelection: false,
      idField: 'item_id',
      textField: 'item_text',
      selectAllText: 'Select All',
      unSelectAllText: 'UnSelect All',
      itemsShowLimit: 3,
      allowSearchFilter: true
    };
  }
  onItemSelect(item: any) {
    console.log(item);
  }
  onSelectAll(items: any) {
    console.log(items);
  }
}


....................
<ng-multiselect-dropdown
  [placeholder]="'custom placeholder'"
  [settings]="dropdownSettings"
  [data]="dropdownList"
  [(ngModel)]="selectedItems"
  (onSelect)="onItemSelect($event)"
  (onSelectAll)="onSelectAll($event)"
>
</ng-multiselect-dropdown>
Comment

PREVIOUS NEXT
Code Example
Typescript :: import tsa test 
Typescript :: call reactdom.render with 2 arguments example 
Typescript :: Write a prolog program to find the sum of elements in given list. 
Typescript :: whcih commands lets you an ip adress log 
Typescript :: let variable name : any = () = { return new typescript fie} 
Typescript :: bts assurance 
Typescript :: how to select a column with brackets in jupyter notebook 
Typescript :: R barplots ggplot 
Typescript :: get popular posts on laravel 
Typescript :: ngsw pwa how to check version update 
Typescript :: difference known_hosts authorized_keys 
Typescript :: typescript optional parameters 
Typescript :: function in c that converts current time in timezone 
Typescript :: best esports game ever 
Typescript :: turn off suspend and sleep tagets system d 
Typescript :: typescript "variable!: type" notation 
Typescript :: group list into sublists python 
Typescript :: typescript dictionary usestate 
Typescript :: calculate fps html canvas 
Typescript :: which of the foolowing ia an element of pallette that holds multiple elements of nspecific purpose 
Typescript :: how to use indexOf in typesript 
Typescript :: yup typescript 
Typescript :: How to separate two similar names from two lists in Python 
Cpp :: interpreter latex matlab 
Cpp :: loop over multidimensional array c++ 
Cpp :: qt qstring to float 
Cpp :: lpcwstr to string c++ 
Cpp :: Runtime Error: Runtime ErrorBad memory access (SIGBUS) 
Cpp :: hello world c++ visual studio 
Cpp :: controlling in windows 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =