[app.component.html]
<ejs-dropdownlist id='games' #dropdown width='150px' [dataSource]='sportsData' [value]='value' [fields]='fields' [placeholder]='waterMark' [popupHeight]='height'></ejs-dropdownlist>
<ejs-grid [dataSource]='data' #grid allowPaging='true' (rowSelected)='rowSelected($event)' (rowDeselected)='rowDeselected($event)' [enableHover]="false" [allowSelection]="true" [selectionSettings]="selectOptions">
<e-columns>
<e-column type='checkbox' width='50'></e-column>
<e-column field='OrderID' isPrimaryKey='true' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='CustomerName' headerText='Customer Name' width='150'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='130' format="yMd" textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></e-column>
<e-column field='ShippedDate' headerText='Shipped Date' width='130' format="yMd" textAlign='Right'></e-column>
</e-columns>
</ejs-grid>
----------------------------------------------------------------------------------------
[app.component.ts]
export class AppComponent {
@ViewChild('dropdown')
public dropdownObj: DropDownListComponent;
@ViewChild('grid')
public gridObj: GridComponent;
----
public ngOnInit(): void {
this.data = orderDetails;
this.selectOptions = { persistSelection: true };
}
rowSelected(args) {
if (this.gridObj.getSelectedRowIndexes().length >= 2) {
this.dropdownObj.enabled = true;
}
else {
this.dropdownObj.enabled = false;
}
}
rowDeselected(args) {
if (this.gridObj.getSelectedRowIndexes().length < 2) {
this.dropdownObj.enabled = false;
}
}
}
|