|
</div>
<ejs-grid #grid [dataSource]='data' allowPaging='true' allowFiltering='true' [pageSettings]="pageOptions">
<e-columns>
...
<e-column field='CustomerID' headerText='Customer ID' width='150' [filterBarTemplate]='templateOptions'></e-column>
<e-column field='OrderDate' headerText='Order Date' type= 'date' format= 'yMd' width='180' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' width='120' [filterBarTemplate]='templateOptionsNumeric' format='C2' textAlign='Right' editType='numericedit'></e-column>
...
</e-columns>
</ejs-grid>
</div> |
|
...
...
this.templateOptions = { // for DropDownList
create: (args: { element: Element, column: Column }) => {
this.dd = <any>document.createElement('select');
this.dd.id = 'CustomerID';
let dataSource: Object[] = orderDatas;
this.option = <any>document.createElement('option');
this.option.value = 'All';
this.option.innerHTML = 'All';
this.dd.appendChild(this.option);
for (let i: number = 0; i < dataSource.length; i++) {
this.option = <any>document.createElement('option');
this.option.value = (<any>dataSource[i]).CustomerID;
this.option.innerHTML = (<any>dataSource[i]).CustomerID;
this.dd.appendChild(this.option);
}
return this.dd;
},
write: (args: { element: Element, column: Column }) => {
this.Drop = new DropDownList({
change: change.bind(this)
});
this.Drop.appendTo(this.dd);
},
};
this.templateOptionsNumeric = { //for NumericTextBox
create: () => {
this.elem = document.createElement('input');
return this.elem;
},
write: (args) => {
this.numeriTextBox = new NumericTextBox({
format: '00.00',
value: 10
});
this.numeriTextBox.appendTo(this.elem);
}
};
}
}
function change(args) {
debugger;
if (args.value !== 'All') {
this.grid.filterByColumn(args.item.parentElement.id.replace('_options', ''), 'equal', args.value);
} else {
this.grid.removeFilteredColsByField(args.item.parentElement.id.replace('_options', ''));
}
}
|