mercredi 15 septembre 2021

Values from API show up in input box but not selected checkboxes of that values using ng-multipleselect-dropdown

HTML file ->

<ng-multiselect-dropdown
     [placeholder]="'Select section'"
     [settings]="dropdownSettings"
     [data]="dropdownList"
     [(ngModel)]="getDropdownValues"
     formControlName="sections"
>
</ng-multiselect-dropdown>

.ts file ->

    this.clientMasterForm = this.formBuilder.group({
            sections: [this.getDropdownValues],
    });
    this.dropdownSettings = {
     singleSelection: false,
     idField: 'id',
     textField: 'sectionName',
     selectAllText: 'Select All',
     unSelectAllText: 'UnSelect All',
     allowSearchFilter: true,
    };
   onItemSelect(item: any) {
    let data = [];
    data.push(item);
    this.selectedDropDownData = data[0];
   }
  onSelectAll(items: any) {
   let data = [];
   data.push(items);
   this.selectedDropDownData = data[0];
  }

   this.getDropdownValues.push(JSON.parse(list).sectionName);

  this.clientMasterForm.get('sections').patchValue(this.getDropdownValues);

Here, I get values that are already added in drop-down patched that value as well but values that are shown in the input box is not selected in checkbox

Here, is my output -> output

Here, I get output as mentioned in above image where I get data but not selected in checkbox




Aucun commentaire:

Enregistrer un commentaire