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 :: apply limit to fetch number of documents firebase firestore 
Typescript :: formControl Server Side rendering 
Typescript :: vue router popstate 
Typescript :: minimum number of cycle shifts for each string if it can be made palindrome 
Typescript :: nunjucks if logical or 
Typescript :: angular jasmine tobe empty array 
Typescript :: The command "composer require barryvdh/laravel-dompdf" always gets an error 
Typescript :: number square n times in typescript 
Typescript :: google sheets past tsv data 
Typescript :: typescript list 
Typescript :: ts string lowercase 
Typescript :: typescript where to put interfaces 
Typescript :: jquery tscroll up 
Typescript :: traits c++ 
Typescript :: .net framework core scaffhold exists table 
Cpp :: how to downgrade numpy 
Cpp :: c++ hide console 
Cpp :: min priority queue c++ 
Cpp :: string hex to int c++ 
Cpp :: c++ system delay 
Cpp :: check if intent has extras 
Cpp :: c++ check if string contains substring 
Cpp :: c++ celsius to fahrenheit 
Cpp :: rapidjson write stringbuffer to file 
Cpp :: can you chnage the address of a pointer 
Cpp :: xmake run with arg 
Cpp :: set precision in c++ 
Cpp :: newline in c++ 
Cpp :: vector of structs c++ 
Cpp :: Vector2 c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =