购买单

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjCore from '@grapecity/wijmo'; import * as wjPdf from '@grapecity/wijmo.pdf'; import * as wjGrid from '@grapecity/wijmo.grid'; import * as wjMultiRow from '@grapecity/wijmo.grid.multirow'; import * as wjGridXlsx from '@grapecity/wijmo.grid.xlsx'; import * as wjGridPdf from '@grapecity/wijmo.grid.pdf'; import { getPurchaseSlip } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let data = getPurchaseSlip(); let purchaseSlip = new wjMultiRow.MultiRow('#purchaseSlip', { itemsSource: data, layoutDefinition: generateLayoutDef() }); purchaseSlip.columnFooters.rows.push(new wjGrid.Row()); purchaseSlip.columnFooters.setCellData(0, 3, 'Summary'); purchaseSlip.columnFooters.setCellData(0, 6, 'Amount Summary'); let cv = purchaseSlip.collectionView; updateSummary(cv); cv.collectionChanged.addHandler((sender, e) => { let quantity, unitCost; if (e.action === wjCore.NotifyCollectionChangedAction.Change && !!e.item) { quantity = +e.item.quantity; unitCost = +e.item.unitCost; if (!isNaN(quantity) && !isNaN(unitCost)) { e.item.cost = quantity * unitCost; e.item.price = e.item.cost * 1.35; updateSummary(cv); } } }); // Generate the layout definition for the MultiRow control. function generateLayoutDef() { let caseDataMap = buildDataMap('small,medium,large'.split(',')); return [ { cells: [ { binding: 'productName', header: 'Product Name', align: 'center', width: 200 } ] }, { cells: [ { binding: 'productId', header: 'Product ID', width: 90 } ] }, { cells: [ { binding: 'color', header: 'Color', align: 'center' }, { binding: 'packageUnit', header: 'Package Unit', align: 'center' } ] }, { cells: [ { binding: 'size', header: 'Size', width: 80 }, { binding: 'case', header: 'Case', dataMap: caseDataMap, width: 80 } ] }, { cells: [ { binding: 'quantity', header: 'Quantity', width: 65 } ] }, { cells: [ { binding: 'deal', header: 'Deal', width: 60 }, { binding: 'id', header: 'ID', width: 60 } ] }, { cells: [ { binding: 'unitCost', header: 'Unit Cost', width: 130, format: 'c2' } ] }, { cells: [ { binding: 'cost', header: 'Cost', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'price', header: 'Price', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'remarks', header: 'Remarks', align: 'center' } ] } ]; } ; // Update the summary info for the MultiRow control. function updateSummary(cv) { let qtySum = wjCore.getAggregate(wjCore.Aggregate.Sum, cv.items, 'quantity'), costSum = wjCore.getAggregate(wjCore.Aggregate.Sum, cv.items, 'cost'), priceSum = wjCore.getAggregate(wjCore.Aggregate.Sum, cv.items, 'price'); purchaseSlip.columnFooters.setCellData(0, 4, qtySum); purchaseSlip.columnFooters.setCellData(0, 7, wjCore.Globalize.format(costSum, 'c2')); purchaseSlip.columnFooters.setCellData(0, 8, wjCore.Globalize.format(priceSum, 'c2')); } function buildDataMap(items) { let map = []; for (let i = 0; i < items.length; i++) { map.push({ key: i, value: items[i] }); } return new wjGrid.DataMap(map, 'key', 'value'); } document.querySelector('#exportXlsx').addEventListener('click', () => { wjGridXlsx.FlexGridXlsxConverter.saveAsync(purchaseSlip, null, 'PurchaseSlip.xlsx'); }); document.querySelector('#exportPdf').addEventListener('click', () => { let doc = new wjPdf.PdfDocument({ header: { declarative: { text: '\t&[Page]\\&[Pages]' } }, footer: { declarative: { text: '\t&[Page]\\&[Pages]' } }, ended: function (sender, args) { wjPdf.saveBlob(args.blob, 'PurchaseSlip.pdf'); } }), settings = { styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6' }, altCellStyle: { backgroundColor: '#f9f9f9' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }; wjGridPdf.FlexGridPdfConverter.draw(purchaseSlip, doc, null, null, settings); doc.end(); }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo MultiRow Purchase Slip</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div id="purchaseSlip"></div> <div class="btn-group"> <button class="btn btn-default" id="exportXlsx"> Export to Excel </button> <button class="btn btn-default" id="exportPdf"> Export to PDF </button> </div> </div> </body> </html> export function getPurchaseSlip() { return [ { productId: 'DC0001', productName: 'Chai', color: 'Red', packageUnit: 12, size: '40*30*20', case: 1, quantity: 15, deal: '', id: '', unitCost: 200, cost: 15 * 200, price: 15 * 200 * 1.35, remarks: '' }, { productId: 'DC0002', productName: 'Chang', color: 'Blue', packageUnit: 16, size: '25*35*25', case: 0, quantity: 10, deal: '', id: '', unitCost: 180, cost: 10 * 180, price: 10 * 180 * 1.35, remarks: '' }, { productId: 'DC0003', productName: 'Aniseed Syrup', color: 'Green', packageUnit: 10, size: '50*40*40', case: 2, quantity: 12, deal: '', id: '', unitCost: 150, cost: 12 * 150, price: 12 * 150 * 1.35, remarks: '' }, { productId: 'DC0004', productName: 'Chef Anton\'s Gumbo Mix', color: 'Yellow', packageUnit: 24, size: '30*40*40', case: 1, quantity: 8, deal: '', id: '', unitCost: 220, cost: 8 * 220, price: 8 * 220 * 1.35, remarks: '' }, { productId: 'DC0005', productName: 'Ikura', color: 'Black', packageUnit: 15, size: '20*20*30', case: 0, quantity: 5, deal: '', id: '', unitCost: 300, cost: 5 * 300, price: 5 * 300 * 1.35, remarks: '' }, { productId: 'DC0006', productName: 'Mishi Kobe Niku', color: 'White', packageUnit: 18, size: '25*20*30', case: 0, quantity: 6, deal: '', id: '', unitCost: 360, cost: 8 * 360, price: 8 * 360 * 1.35, remarks: '' } ]; } .wj-multirow { height: 400px; margin: 6px 0; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as wjCore from '@grapecity/wijmo'; import * as wjGrid from '@grapecity/wijmo.grid'; import * as wjPdf from '@grapecity/wijmo.pdf'; import * as wjMultirow from '@grapecity/wijmo.grid.multirow'; import * as wjGridXlsx from '@grapecity/wijmo.grid.xlsx'; import * as wjGridPdf from '@grapecity/wijmo.grid.pdf'; import { Component, Inject, enableProdMode, NgModule, ViewChild, AfterViewInit } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridMultirowModule } from '@grapecity/wijmo.angular2.grid.multirow'; import { DataService, PurchaseSlip, Line } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent implements AfterViewInit { @ViewChild('purchaseSlip') purchaseSlip: wjMultirow.MultiRow; data: PurchaseSlip[]; layoutDefinition: Line[]; cv: wjCore.CollectionView; // DataSvc will be passed by derived classes constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getPurchaseSlip(); this.layoutDefinition = dataService.generateLayoutDef(); } // ngAfterViewInit() { this.purchaseSlip.columnFooters.rows.push(new wjGrid.Row()); this.purchaseSlip.columnFooters.setCellData(0, 3, 'Summary'); this.purchaseSlip.columnFooters.setCellData(0, 6, 'Amount Summary'); this.cv = <wjCore.CollectionView>this.purchaseSlip.collectionView; this._updateSummary(); this.cv.collectionChanged.addHandler((sender: any, e: wjCore.NotifyCollectionChangedEventArgs) => { let quantity: number, unitCost: number; if (e.action === wjCore.NotifyCollectionChangedAction.Change && !!e.item) { quantity = +e.item.quantity; unitCost = +e.item.unitCost; if (!isNaN(quantity) && !isNaN(unitCost)) { e.item.cost = quantity * unitCost; e.item.price = e.item.cost * 1.35; this._updateSummary(); } } }); } // onExportXlsxClick() { wjGridXlsx.FlexGridXlsxConverter.saveAsync(this.purchaseSlip, null, 'PurchaseSlip.xlsx'); } // onExportPdfClick() { let doc = new wjPdf.PdfDocument({ header: { declarative: { text: '\t&[Page]\\&[Pages]' } }, footer: { declarative: { text: '\t&[Page]\\&[Pages]' } }, ended: function (sender: wjPdf.PdfDocument, args: wjPdf.PdfDocumentEndedEventArgs) { wjPdf.saveBlob(args.blob, 'PurchaseSlip.pdf'); } }), settings = { styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6' }, altCellStyle: { backgroundColor: '#C0FFC0' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }; wjGridPdf.FlexGridPdfConverter.draw(this.purchaseSlip, doc, null, null, settings); doc.end(); } // private _updateSummary() { let qtySum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'quantity'), costSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'cost'), priceSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'price'); this.purchaseSlip.columnFooters.setCellData(0, 4, qtySum); this.purchaseSlip.columnFooters.setCellData(0, 7, wjCore.Globalize.format(costSum, 'c2')); this.purchaseSlip.columnFooters.setCellData(0, 8, wjCore.Globalize.format(priceSum, 'c2')); } } //\\ @NgModule({ imports: [WjGridMultirowModule, BrowserModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo MultiRow Purchase Slip</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <wj-multi-row #purchaseSlip [itemsSource]="data" [layoutDefinition]="layoutDefinition"></wj-multi-row> <div class="btn-group"> <button class="btn btn-default" (click)="onExportXlsxClick()"> Export to Excel </button> <button class="btn btn-default" (click)="onExportPdfClick()"> Export to PDF </button> </div> </div> import { Injectable } from '@angular/core'; import * as wjGrid from '@grapecity/wijmo.grid'; export interface PurchaseSlip { productId: string; productName: string; color: string; packageUnit: number; size: string; case: number; quantity: number; deal: string; id: string; unitCost: number; cost: number; price: number; remarks: string; } export interface Cell { binding: string; header: string; cssClass?: string; format?: string; isReadOnly?: boolean; wordWrap?: boolean; width?: number; colspan?: number; align?: string; dataMap?: wjGrid.DataMap; } export interface Line { cells: Cell[]; } @Injectable() export class DataService { getPurchaseSlip(): PurchaseSlip[] { return [ { productId: 'DC0001', productName: 'Chai', color: 'Red', packageUnit: 12, size: '40*30*20', case: 1, quantity: 15, deal: '', id: '', unitCost: 200, cost: 15 * 200, price: 15 * 200 * 1.35, remarks: '' }, { productId: 'DC0002', productName: 'Chang', color: 'Blue', packageUnit: 16, size: '25*35*25', case: 0, quantity: 10, deal: '', id: '', unitCost: 180, cost: 10 * 180, price: 10 * 180 * 1.35, remarks: '' }, { productId: 'DC0003', productName: 'Aniseed Syrup', color: 'Green', packageUnit: 10, size: '50*40*40', case: 2, quantity: 12, deal: '', id: '', unitCost: 150, cost: 12 * 150, price: 12 * 150 * 1.35, remarks: '' }, { productId: 'DC0004', productName: 'Chef Anton\'s Gumbo Mix', color: 'Yellow', packageUnit: 24, size: '30*40*40', case: 1, quantity: 8, deal: '', id: '', unitCost: 220, cost: 8 * 220, price: 8 * 220 * 1.35, remarks: '' }, { productId: 'DC0005', productName: 'Ikura', color: 'Black', packageUnit: 15, size: '20*20*30', case: 0, quantity: 5, deal: '', id: '', unitCost: 300, cost: 5 * 300, price: 5 * 300 * 1.35, remarks: '' }, { productId: 'DC0006', productName: 'Mishi Kobe Niku', color: 'White', packageUnit: 18, size: '25*20*30', case: 0, quantity: 6, deal: '', id: '', unitCost: 360, cost: 8 * 360, price: 8 * 360 * 1.35, remarks: '' } ]; } generateLayoutDef(): Line[] { let caseDataMap = buildDataMap('small,medium,large'.split(',')); return [ { cells: [ { binding: 'productName', header: 'Product Name', align: 'center', width: 200 } ] }, { cells: [ { binding: 'productId', header: 'Product ID', width: 90 } ] }, { cells: [ { binding: 'color', header: 'Color', align: 'center' }, { binding: 'packageUnit', header: 'Package Unit', align: 'center' } ] }, { cells: [ { binding: 'size', header: 'Size', width: 80 }, { binding: 'case', header: 'Case', dataMap: caseDataMap, width: 80 } ] }, { cells: [ { binding: 'quantity', header: 'Quantity', width: 65 } ] }, { cells: [ { binding: 'deal', header: 'Deal', width: 60 }, { binding: 'id', header: 'ID', width: 60 } ] }, { cells: [ { binding: 'unitCost', header: 'Unit Cost', width: 130, format: 'c2' } ] }, { cells: [ { binding: 'cost', header: 'Cost', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'price', header: 'Price', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'remarks', header: 'Remarks', align: 'center' } ] } ]; } } function buildDataMap(items: string[]) { let map = []; for (let i = 0; i < items.length; i++) { map.push({ key: i, value: items[i] }); } return new wjGrid.DataMap(map, 'key', 'value'); } .wj-multirow { height: 400px; margin: 6px 0; } <template> <div class="container-fluid"> <wj-multi-row :initialized="initSlip" :itemsSource="data" :layoutDefinition="layoutDefinition"></wj-multi-row> <div class="btn-group"> <button class="btn btn-default" @click="onExportXlsxClick"> Export to Excel </button> <button class="btn btn-default" @click="onExportPdfClick"> Export to PDF </button> </div> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.core'; import '@grapecity/wijmo.vue2.grid.multirow'; import * as wjCore from '@grapecity/wijmo'; import * as wjGrid from '@grapecity/wijmo.grid'; import * as wjPdf from '@grapecity/wijmo.pdf'; import * as wjGridXlsx from '@grapecity/wijmo.grid.xlsx'; import * as wjGridPdf from '@grapecity/wijmo.grid.pdf'; import { getPurchaseSlip, generateLayoutDef } from './data'; let App = Vue.extend({ name: 'app', data: function(){ return { data: getPurchaseSlip(), layoutDefinition: generateLayoutDef(), purchaseSlip: null } }, methods: { initSlip: function(purchaseSlip){ this.purchaseSlip = purchaseSlip; }, onExportXlsxClick: function() { wjGridXlsx.FlexGridXlsxConverter.saveAsync(this.purchaseSlip, null, 'PurchaseSlip.xlsx'); }, onExportPdfClick: function() { let doc = new wjPdf.PdfDocument({ header: { declarative: { text: '\t&[Page]\\&[Pages]' } }, footer: { declarative: { text: '\t&[Page]\\&[Pages]' } }, ended: function (sender, args) { wjPdf.saveBlob(args.blob, 'PurchaseSlip.pdf'); } }), settings = { styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6' }, altCellStyle: { backgroundColor: '#C0FFC0' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }; wjGridPdf.FlexGridPdfConverter.draw(this.purchaseSlip, doc, null, null, settings); doc.end(); }, _updateSummary: function() { let qtySum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'quantity'), costSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'cost'), priceSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.cv.items, 'price'); this.purchaseSlip.columnFooters.setCellData(0, 4, qtySum); this.purchaseSlip.columnFooters.setCellData(0, 7, wjCore.Globalize.format(costSum, 'c2')); this.purchaseSlip.columnFooters.setCellData(0, 8, wjCore.Globalize.format(priceSum, 'c2')); } }, mounted: function(){ this.purchaseSlip.columnFooters.rows.push(new wjGrid.Row()); this.purchaseSlip.columnFooters.setCellData(0, 3, 'Summary'); this.purchaseSlip.columnFooters.setCellData(0, 6, 'Amount Summary'); this.cv = this.purchaseSlip.collectionView; this._updateSummary(); this.cv.collectionChanged.addHandler((sender, e) => { let quantity, unitCost; if (e.action === wjCore.NotifyCollectionChangedAction.Change && !!e.item) { quantity = +e.item.quantity; unitCost = +e.item.unitCost; if (!isNaN(quantity) && !isNaN(unitCost)) { e.item.cost = quantity * unitCost; e.item.price = e.item.cost * 1.35; this._updateSummary(); } } }); } }); new Vue({ render: h => h(App) }).$mount('#app'); </script> <style> .wj-multirow { height: 400px; margin: 6px 0; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/jszip/dist/jszip.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> import * as wjGrid from '@grapecity/wijmo.grid'; export function getPurchaseSlip(){ return [ { productId: 'DC0001', productName: 'Chai', color: 'Red', packageUnit: 12, size: '40*30*20', case: 1, quantity: 15, deal: '', id: '', unitCost: 200, cost: 15 * 200, price: 15 * 200 * 1.35, remarks: '' }, { productId: 'DC0002', productName: 'Chang', color: 'Blue', packageUnit: 16, size: '25*35*25', case: 0, quantity: 10, deal: '', id: '', unitCost: 180, cost: 10 * 180, price: 10 * 180 * 1.35, remarks: '' }, { productId: 'DC0003', productName: 'Aniseed Syrup', color: 'Green', packageUnit: 10, size: '50*40*40', case: 2, quantity: 12, deal: '', id: '', unitCost: 150, cost: 12 * 150, price: 12 * 150 * 1.35, remarks: '' }, { productId: 'DC0004', productName: 'Chef Anton\'s Gumbo Mix', color: 'Yellow', packageUnit: 24, size: '30*40*40', case: 1, quantity: 8, deal: '', id: '', unitCost: 220, cost: 8 * 220, price: 8 * 220 * 1.35, remarks: '' }, { productId: 'DC0005', productName: 'Ikura', color: 'Black', packageUnit: 15, size: '20*20*30', case: 0, quantity: 5, deal: '', id: '', unitCost: 300, cost: 5 * 300, price: 5 * 300 * 1.35, remarks: '' }, { productId: 'DC0006', productName: 'Mishi Kobe Niku', color: 'White', packageUnit: 18, size: '25*20*30', case: 0, quantity: 6, deal: '', id: '', unitCost: 360, cost: 8 * 360, price: 8 * 360 * 1.35, remarks: '' } ]; } export function generateLayoutDef(){ let caseDataMap = buildDataMap('small,medium,large'.split(',')); return [ { cells: [ { binding: 'productName', header: 'Product Name', align: 'center', width: 200 } ] }, { cells: [ { binding: 'productId', header: 'Product ID', width: 90 } ] }, { cells: [ { binding: 'color', header: 'Color', align: 'center' }, { binding: 'packageUnit', header: 'Package Unit', align: 'center' } ] }, { cells: [ { binding: 'size', header: 'Size', width: 80 }, { binding: 'case', header: 'Case', dataMap: caseDataMap, width: 80 } ] }, { cells: [ { binding: 'quantity', header: 'Quantity', width: 65 } ] }, { cells: [ { binding: 'deal', header: 'Deal', width: 60 }, { binding: 'id', header: 'ID', width: 60 } ] }, { cells: [ { binding: 'unitCost', header: 'Unit Cost', width: 130, format: 'c2' } ] }, { cells: [ { binding: 'cost', header: 'Cost', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'price', header: 'Price', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'remarks', header: 'Remarks', align: 'center' } ] } ]; } function buildDataMap(items) { let map = []; for (let i = 0; i < items.length; i++) { map.push({ key: i, value: items[i] }); } return new wjGrid.DataMap(map, 'key', 'value'); } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './app.css'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjMultiRow from '@grapecity/wijmo.react.grid.multirow'; import * as wjGrid from '@grapecity/wijmo.grid'; import * as wjCore from '@grapecity/wijmo'; import * as wjPdf from '@grapecity/wijmo.pdf'; import * as wjGridXlsx from '@grapecity/wijmo.grid.xlsx'; import * as wjGridPdf from '@grapecity/wijmo.grid.pdf'; import { generateLayoutDef, getPurchaseSlip } from './data'; class App extends React.Component { constructor(props) { super(props); this.initialized = (purchaseSlip) => { this.setState({ purchaseSlip: purchaseSlip, cv: purchaseSlip.collectionView }, () => { this.state.purchaseSlip.columnFooters.rows.push(new wjGrid.Row()); this.state.purchaseSlip.columnFooters.setCellData(0, 3, 'Summary'); this.state.purchaseSlip.columnFooters.setCellData(0, 6, 'Amount Summary'); this._updateSummary(); let cv = this.state.cv; cv.collectionChanged.addHandler((sender, e) => { let quantity, unitCost; if (e.action === wjCore.NotifyCollectionChangedAction.Change && !!e.item) { quantity = +e.item.quantity; unitCost = +e.item.unitCost; if (!isNaN(quantity) && !isNaN(unitCost)) { e.item.cost = quantity * unitCost; e.item.price = e.item.cost * 1.35; this._updateSummary(); } } }); }); }; this.onExportXlsxClick = () => { wjGridXlsx.FlexGridXlsxConverter.saveAsync(this.state.purchaseSlip, null, 'PurchaseSlip.xlsx'); }; this.onExportPdfClick = () => { let doc = new wjPdf.PdfDocument({ header: { declarative: { text: '\t&[Page]\\&[Pages]' } }, footer: { declarative: { text: '\t&[Page]\\&[Pages]' } }, ended: function (sender, args) { wjPdf.saveBlob(args.blob, 'PurchaseSlip.pdf'); } }), settings = { styles: { cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6' }, altCellStyle: { backgroundColor: '#C0FFC0' }, headerCellStyle: { backgroundColor: '#eaeaea' } } }; wjGridPdf.FlexGridPdfConverter.draw(this.state.purchaseSlip, doc, null, null, settings); doc.end(); }; this._updateSummary = () => { let qtySum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.state.cv.items, 'quantity'), costSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.state.cv.items, 'cost'), priceSum = wjCore.getAggregate(wjCore.Aggregate.Sum, this.state.cv.items, 'price'); this.state.purchaseSlip.columnFooters.setCellData(0, 4, qtySum); this.state.purchaseSlip.columnFooters.setCellData(0, 7, wjCore.Globalize.format(costSum, 'c2')); this.state.purchaseSlip.columnFooters.setCellData(0, 8, wjCore.Globalize.format(priceSum, 'c2')); }; this.state = { data: getPurchaseSlip(), layoutDefinition: generateLayoutDef(), purchaseSlip: null, cv: null }; } ; componentDidMount() { } render() { return <div className="container-fluid"> <wjMultiRow.MultiRow id="orderDetail" itemsSource={this.state.data} layoutDefinition={this.state.layoutDefinition} initialized={this.initialized}></wjMultiRow.MultiRow> <div className="btn-group"> <button className="btn btn-default" onClick={this.onExportXlsxClick}> Export to Excel </button> <button className="btn btn-default" onClick={this.onExportPdfClick}> Export to PDF </button> </div> </div>; } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/jszip/dist/jszip.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> .wj-multirow { height: 400px; margin: 6px 0; } import * as wjGrid from '@grapecity/wijmo.grid'; export function getPurchaseSlip() { return [ { productId: 'DC0001', productName: 'Chai', color: 'Red', packageUnit: 12, size: '40*30*20', case: 1, quantity: 15, deal: '', id: '', unitCost: 200, cost: 15 * 200, price: 15 * 200 * 1.35, remarks: '' }, { productId: 'DC0002', productName: 'Chang', color: 'Blue', packageUnit: 16, size: '25*35*25', case: 0, quantity: 10, deal: '', id: '', unitCost: 180, cost: 10 * 180, price: 10 * 180 * 1.35, remarks: '' }, { productId: 'DC0003', productName: 'Aniseed Syrup', color: 'Green', packageUnit: 10, size: '50*40*40', case: 2, quantity: 12, deal: '', id: '', unitCost: 150, cost: 12 * 150, price: 12 * 150 * 1.35, remarks: '' }, { productId: 'DC0004', productName: 'Chef Anton\'s Gumbo Mix', color: 'Yellow', packageUnit: 24, size: '30*40*40', case: 1, quantity: 8, deal: '', id: '', unitCost: 220, cost: 8 * 220, price: 8 * 220 * 1.35, remarks: '' }, { productId: 'DC0005', productName: 'Ikura', color: 'Black', packageUnit: 15, size: '20*20*30', case: 0, quantity: 5, deal: '', id: '', unitCost: 300, cost: 5 * 300, price: 5 * 300 * 1.35, remarks: '' }, { productId: 'DC0006', productName: 'Mishi Kobe Niku', color: 'White', packageUnit: 18, size: '25*20*30', case: 0, quantity: 6, deal: '', id: '', unitCost: 360, cost: 8 * 360, price: 8 * 360 * 1.35, remarks: '' } ]; } export function generateLayoutDef() { let caseDataMap = buildDataMap('small,medium,large'.split(',')); return [ { cells: [ { binding: 'productName', header: 'Product Name', align: 'center', width: 200 } ] }, { cells: [ { binding: 'productId', header: 'Product ID', width: 90 } ] }, { cells: [ { binding: 'color', header: 'Color', align: 'center' }, { binding: 'packageUnit', header: 'Package Unit', align: 'center' } ] }, { cells: [ { binding: 'size', header: 'Size', width: 80 }, { binding: 'case', header: 'Case', dataMap: caseDataMap, width: 80 } ] }, { cells: [ { binding: 'quantity', header: 'Quantity', width: 65 } ] }, { cells: [ { binding: 'deal', header: 'Deal', width: 60 }, { binding: 'id', header: 'ID', width: 60 } ] }, { cells: [ { binding: 'unitCost', header: 'Unit Cost', width: 130, format: 'c2' } ] }, { cells: [ { binding: 'cost', header: 'Cost', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'price', header: 'Price', width: 90, format: 'c2', isReadOnly: true } ] }, { cells: [ { binding: 'remarks', header: 'Remarks', align: 'center' } ] } ]; } function buildDataMap(items) { let map = []; for (let i = 0; i < items.length; i++) { map.push({ key: i, value: items[i] }); } return new wjGrid.DataMap(map, 'key', 'value'); }