|
@Component({
selector: 'my-app',
template: `<ejs-multiselect id='multiselectelement' #samples1(created)='onCreate($event)' [dataSource]='sportsData' [fields]='fields'[placeholder]='placeholder'></ejs-multiselect>`,
// include the material theme to AutoComplete,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
name = 'Angular 6';
@ViewChild('samples1')
public ddlObject1: MultiSelectComponent;
//set the data to dataSource property
public sportsData: Object[] = [
{ id: 'Game1', sports: 'Badminton'}, //, selected: true
{ id: 'Game2', sports: 'Basketball'},
{ id: 'Game3', sports: 'Cricket'},
{ id: 'Game4', sports: 'Football' },
{ id: 'Game5', sports: 'Golf' }
];
// maps the appropriate column to fields property
public fields: Object = { text: 'sports', value: 'id' };
// set placeholder to MultiSelect input element
public placeholder: string = 'Select games';
onCreate(args: any): void{
this.ddlObject1.selectAll(true);
}
} |
|
@Component({
selector: 'my-app',
template: `<ejs-multiselect id='multiselectelement' #samples1 (created)='onCreate($event)' [readonly]=readonly [dataSource]='sportsData' [fields]='fields'[placeholder]='placeholder'></ejs-multiselect><ejs-dropdownlist id='ddlelement' #samples [dataSource]='sportsData' [fields]='fields' [placeholder]='placeholder' [readonly]='readonly'></ejs-dropdownlist>
`,
// include the material theme to AutoComplete,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
name = 'Angular 6';
@ViewChild('samples1')
public ddlObject1: MultiSelectComponent;
//set the data to dataSource property
public sportsData: Object[] = [
{ id: 'Game1', sports: 'Badminton'}, //, selected: true
{ id: 'Game2', sports: 'Basketball'},
{ id: 'Game3', sports: 'Cricket'},
{ id: 'Game4', sports: 'Football' },
{ id: 'Game5', sports: 'Golf' }
];
// maps the appropriate column to fields property
public fields: Object = { text: 'sports', value: 'id' };
// set placeholder to MultiSelect input element
public placeholder: string = 'Select games';
public readonly: boolean = true;
onCreate(args: any): void{
this.ddlObject1.selectAll(true);
}
}
|
|
@ViewChild('samples1')
public ddlObject1: MultiSelectComponent;
…..
this.ddlObject1.readonly=false;
|
I was getting beow error while trying to do the same.
To solve this issue, I put the expression inside setTimeout.
Hi Ketan,
We have validated the reported query on our end. Unfortunately, we couldn’t reproduce the reported issue as per your scenario. We have shared a simple working sample for your reference. Please refer to the shared code snippet and sample for more details.
[app.component.html]
<ejs-multiselect #samples1 id="multiselect-grouping" [dataSource]="vegetableData" [placeholder]="groupWaterMark" [fields]="groupFields" (created)='onCreate($event)' ></ejs-multiselect> |
[app.component.ts]
export class AppComponent { @ViewChild('samples1') public ddlObject1: MultiSelectComponent;
public vegetableData: { [key: string]: Object }[] = [ { Vegetable: 'Cabbage', Category: 'Leafy and Salad', Id: 'item1' }, { Vegetable: 'Chickpea', Category: 'Beans', Id: 'item2' }, { Vegetable: 'Garlic', Category: 'Bulb and Stem', Id: 'item3' }, { Vegetable: 'Green bean', Category: 'Beans', Id: 'item4' }, { Vegetable: 'Horse gram', Category: 'Beans', Id: 'item5' } ];
public groupFields: Object = { text: 'Vegetable', value: 'Id', };
public groupWaterMark: string = 'Select vegetables';
onCreate(args: any): void { this.ddlObject1.selectAll(true); } } |
Sample : https://stackblitz.com/edit/angular-pkg8gt?file=app.component.ts,app.component.html
Kindly try the above suggestion and let us know if this meets your requirement. If you still face the same issue, we request that you provide additional details about the issue as mentioned below. This will help us validate the issue further and provide you with a better solution.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D