taffy-coustom-ui
Version:
64 lines (53 loc) • 2.01 kB
text/typescript
import { Component, ViewChild } from '@angular/core';
import { jqxGridComponent } from 'jqwidgets-ng/jqxgrid'
import { generatedata } from './../../../sampledata/generatedata';
({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
('myGrid', { static: false }) myGrid: jqxGridComponent;
source: any =
{
localdata: generatedata(500, false),
datafields:
[
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' },
{ name: 'productname', type: 'string' },
{ name: 'date', type: 'date' },
{ name: 'quantity', type: 'number' },
{ name: 'price', type: 'number' }
],
datatype: 'array'
};
getWidth() : any {
if (document.body.offsetWidth < 850) {
return '90%';
}
return 850;
}
dataAdapter: any = new jqx.dataAdapter(this.source);
columns: any[] =
[
{ text: 'First Name', datafield: 'firstname', width: 160 },
{ text: 'Last Name', datafield: 'lastname', width: 160 },
{ text: 'Product', datafield: 'productname', width: 170 },
{ text: 'Order Date', datafield: 'date', filtertype: 'date', width: 160, cellsformat: 'dd-MMMM-yyyy' },
{ text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right' },
{ text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }
];
firstNameColumnFilter = (): void => {
let filtergroup = new jqx.filter();
let filter_or_operator = 1;
let filtervalue = 'Nancy';
let filtercondition = 'contains';
let filter = filtergroup.createfilter('stringfilter', filtervalue, filtercondition);
filtergroup.addfilter(filter_or_operator, filter);
this.myGrid.addfilter('firstname', filtergroup);
this.myGrid.applyfilters();
};
ready = (): void => {
this.firstNameColumnFilter();
}
}