|
<ejs-multiselect id="multiselect-checkbox" #checkbox [dataSource]="countries" [placeholder]="checkWaterMark" [fields]="checkFields" [mode]="mode" [popupHeight]="popHeight" [showDropDownIcon]="true" showSelectAll="true" cssClass="custom" [filterBarPlaceholder]="filterPlaceholder" (select)="onSelect($event)" (filtering)="onFilter($event)"></ejs-multiselect>
|
|
public onSelect(args) {
if (args.itemData.Code == '5') {
var liCollections = document.querySelectorAll('.e-popup.custom .e-list-item');
for (var i = 0; i < liCollections.length; i++) {
if ((liCollections[i] as any).innerText == 'Pod A') {
liCollections[i].classList.add('e-disabled');
liCollections[i].classList.add('e-overlay');
}
}
}
} |
|
public onFilter(args) {
if (this.mulObj.value && this.mulObj.value.includes('5' as never)) {
setTimeout(() => {
var liCollections = document.querySelectorAll('.e-popup.custom .e-list-item');
for (var i = 0; i < liCollections.length; i++) {
if ((liCollections[i] as any).innerText == 'Pod A') {
liCollections[i].classList.add('e-disabled');
liCollections[i].classList.add('e-overlay');
}
}
}, 10);
}
} |
|
|
|
public onSelect(args) {
if (args.itemData.Code == '5') {
var liCollections = document.querySelectorAll('.e-popup.custom .e-list-item');
for (var i = 0; i < liCollections.length; i++) {
if ((liCollections[i] as any).innerText == 'Pod A') {
if (liCollections[i].querySelector('.e-check')) {
liCollections[i].querySelector('.e-check').classList.remove('e-check');
}
liCollections[i].classList.add('e-disabled');
liCollections[i].classList.add('e-overlay');
}
}
}
}
|
|
[app.component.html]
<button (click)="saveAction($event)">Submit</button>
<ejs-grid
#grid
[dataSource]="data"
allowPaging="true"
[pageSettings]="pageSettings"
[allowSorting]="true"
>
<e-columns>
<e-column
field="Feature"
[isPrimaryKey]="true"
headerText="Feature"
width="120"
textAlign="Right"
></e-column>
<e-column headerText="Pod Assignment" width="150">
<ng-template #template let-data>
<div>
<ejs-multiselect
#multiselectCheckbox
name="multiselectCheckbox"
id="multiselectCheckbox"
[dataSource]="aPods"
[placeholder]="checkWaterMark"
[fields]="podFields"
[mode]="mode"
[popupHeight]="popHeight"
[showDropDownIcon]="true"
showSelectAll="true"
[(ngModel)]="data.podAssign"
[value]="data.podAssign"
(blur)="multiSelectFocusout($event)"
>
</ejs-multiselect></div
></ng-template>
</e-column>
</e-columns>
</ejs-grid> |
|
[app.component.ts]
saveAction(args) {
console.log(this.grid.dataSource);
}
multiSelectFocusout(args) {
if ((event as Event).target.classList.contains('e-dropdownbase')) {
var multiSelectDropdown = event.target.closest('.e-multiselect')
.parentElement.ej2_instances[0];
var rowObj = this.grid.getRowInfo(event.target);
rowObj.rowData['podAssign'] = multiSelectDropdown.value;
this.grid.setRowData(
this.grid.getPrimaryKeyFieldNames()[0],
rowObj.rowData
);
}
} |
I am getting compile error for the squiggle's from your example classList and closestI am using Angular 9z
From Package.json"@angular/animations": "^9.1.13","@angular/common": "^9.1.13","@angular/compiler": "^9.1.13","@angular/core": "^9.1.13","@angular/forms": "^9.1.13","@angular/platform-browser": "^9.1.13","@angular/platform-browser-dynamic": "^9.1.13","@angular/router": "^9.1.13","@syncfusion/ej2-angular-base": "*","@syncfusion/ej2-angular-buttons": "*","@syncfusion/ej2-angular-calendars": "*","@syncfusion/ej2-angular-charts": "*","@syncfusion/ej2-angular-diagrams": "*","@syncfusion/ej2-angular-dropdowns": "*","@syncfusion/ej2-angular-gantt": "*","@syncfusion/ej2-angular-grids": "*","@syncfusion/ej2-angular-heatmap": "*","@syncfusion/ej2-angular-inputs": "*","@syncfusion/ej2-angular-kanban": "*","@syncfusion/ej2-angular-navigations": "*","@syncfusion/ej2-angular-notifications": "*","@syncfusion/ej2-angular-popups": "*","@syncfusion/ej2-angular-progressbar": "*","@syncfusion/ej2-angular-richtexteditor": "*","@syncfusion/ej2-angular-spreadsheet": "*","@syncfusion/ej2-base": "*","@syncfusion/ej2-buttons": "*","@syncfusion/ej2-calendars": "*","@syncfusion/ej2-charts": "*","@syncfusion/ej2-diagrams": "*","@syncfusion/ej2-dropdowns": "*","@syncfusion/ej2-gantt": "*","@syncfusion/ej2-grids": "*","@syncfusion/ej2-heatmap": "*","@syncfusion/ej2-inputs": "*","@syncfusion/ej2-kanban": "*","@syncfusion/ej2-navigations": "*","@syncfusion/ej2-notifications": "*","@syncfusion/ej2-popups": "*","@syncfusion/ej2-progressbar": "*","@syncfusion/ej2-richtexteditor": "*","@syncfusion/ej2-spreadsheet": "*","@syncfusion/ej2-layouts": "*","@syncfusion/ej2-angular-layouts": "*","bootstrap": "^4.5.2","classlist.js": "^1.1.20150312","install": "^0.13.0","jquery": "^3.6.0","moment": "^2.29.1","ngx-moment": "^5.0.0","popper.js": "^1.16.1","rxjs": "6.5.5","ts": "^0.2.2","tslib": "^1.10.0","xlsx": "^0.16.9","zone.js": "~0.10.2"ALso when there is a validation error, i need to show. when data.isError is trueThe error is not reflectingWhen i refresh the grid.refresh() to show the error, the new selections are getting reset in MultiselectHow do i show error and retain values in multiselect<ejs-grid #gridCAssignments [dataSource]='aPodAssignments'[allowPaging]='true' [allowSorting]='true'[pageSettings]='pageOptions' [allowFiltering]='true'[filterSettings]='filterOptions' [allowResizing]='true'><e-columns><e-column field='name' headerText='Feature' textAlign='Left'width=90>e-column><e-column headerText='Pod Assignment' textAlign='Left'width=90><ng-template #template let-data><div><ejs-multiselect #multiselectCheckboxname="multiselectCheckbox"id="multiselectCheckbox"[dataSource]='aPods'[placeholder]='checkWaterMark'[fields]='podFields' [mode]='mode'[popupHeight]='popHeight'[showDropDownIcon]='true'showSelectAll='true'[filterBarPlaceholder]='filterPlaceholder'cssClass="custom-{{data.itemId}}"[(ngModel)]="data.podSelValue" [value]="data.podSelValue"(change)="changevalue($event, data)" >ejs-multiselect><div *ngIf=" data.isError"class="alert alert-danger">Cannot select group items with individual items.div>div>ng-template>e-column>e-columns>ejs-grid>
|
App.component.ts
multiSelectFocusout(args) {
var target = (event as FocusEvent).target as Element;
if (target.classList.contains('e-dropdownbase')) {
var multiSelectDropdown = (parentsUntil(target, 'e-multiselect', false)
.parentElement as EJ2Intance).ej2_instances[0];
var rowObj = this.grid.getRowInfo(target);
rowObj.rowData['podAssign'] = multiSelectDropdown.value;
this.changedData.push(rowObj.rowData);
this.grid.setRowData(
this.grid.getPrimaryKeyFieldNames()[0],
rowObj.rowData
);
}
} |
|
App.component.ts
saveAction(args) {
console.log(this.changedData); // Get the Grid rows based on selected multiselect dropdown items
this.changedData = []; // we have reset the changed data here
}
multiSelectFocusout(args) {
var target = (event as FocusEvent).target as Element;
if (target.classList.contains('e-dropdownbase')) {
var multiSelectDropdown = (parentsUntil(target, 'e-multiselect', false)
.parentElement as EJ2Intance).ej2_instances[0];
var rowObj = this.grid.getRowInfo(target);
rowObj.rowData['podAssign'] = multiSelectDropdown.value;
this.changedData.push(rowObj.rowData);
this.grid.setRowData(
this.grid.getPrimaryKeyFieldNames()[0],
rowObj.rowData
);
}
} |