jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
117 lines (106 loc) • 3.14 kB
text/typescript
/// <reference path='components/jqwidgets.d.ts' />
import { Component, ViewChild, AfterViewInit, Input, Directive } from '@angular/core';
import { jqxGridComponent } from 'components/angular_jqxgrid';
export class GridComponent implements AfterViewInit
{
myGrid: jqxGridComponent;
employeID: number = 1;
quarter: number = 1;
ngAfterViewInit(): void
{
this.myGrid.createWidget(this.settings);
}
//Refresh the grid when the employeID оr quarter is changed
refreshGrid(): void
{
setTimeout(() =>
{
this.myGrid.updatebounddata('cells');
}, 100)
};
//Grid Setup
arrayOfGridOrdersData = [];
sourceGrid = {
datatype: 'json',
datafields: [
{ name: 'ShippedDate', type: 'date' },
{ name: 'ShipAddress' },
{ name: 'Customer', type: 'string' },
{ name: 'Amount', type: 'number' }
],
beforeprocessing: (data) =>
{
if (data)
{
for (let item in data)
{
this.arrayOfGridOrdersData[item] = data[item];
}
}
},
updaterow: (rowid, rowdata, commit) =>
{
commit(true);
},
url: '../personalsales/data.php'
};
dataAdapter = new $.jqx.dataAdapter(this.sourceGrid, {
formatData: (data) =>
{
$.extend(data, {
employeeid: this.employeID,
month: this.quarter,
usedwidget: 'salesgrid'
});
return data;
},
autoBind: true
});
settings: jqwidgets.GridOptions = {
width: '100%',
theme: 'light',
autoheight: true,
clipboard: false,
altrows: true,
rowsheight: 35,
pagermode: 'simple',
ready: () =>
{
let localizationobj = { thousandsseparator: '' };
this.myGrid.localizestrings(localizationobj);
},
source: this.dataAdapter,
columns: [
{
text: 'Date',
datafield: 'ShippedDate',
width: '15%',
cellsformat: 'MMM dd yyyy',
cellsalign: 'center'
},
{
width: '35%',
text: 'Ship Address',
datafield: 'ShipAddress',
cellsalign: 'center'
},
{
width: '15%',
text: 'Customer',
datafield: 'Customer',
cellsalign: 'center'
},
{
width: '35%',
text: 'Amount',
datafield: 'Amount',
cellsformat: 'c2',
cellsalign: 'right'
}
]
}
}