Multiple Headers

FlexSheet supports multiple row headers and column headers.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjGrid from '@grapecity/wijmo.grid'; import * as wjFlexSheet from '@grapecity/wijmo.grid.sheet'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let multiHeadersSheet = new wjFlexSheet.FlexSheet('#multiHeadersSheet'); multiHeadersSheet.addUnboundSheet('unbound', 20, 10); multiHeadersSheet.deferUpdate(() => { for (let row = 0; row < multiHeadersSheet.rows.length; row++) { for (let col = 0; col < multiHeadersSheet.columns.length; col++) { multiHeadersSheet.setCellData(row, col, row + col); } } }); onClick('addRowHeader', () => { multiHeadersSheet.rowHeaders.columns.push(new wjGrid.Column()); }); onClick('removeRowHeader', () => { let colCnt = multiHeadersSheet.rowHeaders.columns.length; if (colCnt > 0) { multiHeadersSheet.rowHeaders.columns.removeAt(colCnt - 1); } }); onClick('addColumnHeader', () => { multiHeadersSheet.columnHeaders.rows.push(new wjGrid.Row()); }); onClick('removeColumnHeader', () => { let rowCnt = multiHeadersSheet.columnHeaders.rows.length; if (rowCnt > 0) { multiHeadersSheet.columnHeaders.rows.removeAt(rowCnt - 1); } }); function onClick(id, fn) { document.querySelector('#' + id).addEventListener('click', fn); } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexSheet Multiple Headers</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="multiHeadersSheet"></div> <div class="row well well-lg"> <div class="btn-group"> <button type="button" class="btn btn-default" id="addRowHeader">Add Row Header</button> <button type="button" class="btn btn-default" id="removeRowHeader">Remove Row Header</button> <button type="button" class="btn btn-default" id="addColumnHeader">Add Column Header</button> <button type="button" class="btn btn-default" id="removeColumnHeader">Remove Column Header</button> </div> </div> </div> </body> </html> .wj-flexsheet { height: 400px; margin: 6px 0; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import { Component, enableProdMode, NgModule, ViewChild } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridSheetModule } from '@grapecity/wijmo.angular2.grid.sheet'; import * as wjcGrid from '@grapecity/wijmo.grid'; import * as wjcSheet from '@grapecity/wijmo.grid.sheet'; @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { @ViewChild('flex') flex: wjcSheet.FlexSheet; initializeFlexSheet(flex: wjcSheet.FlexSheet) { flex.deferUpdate(() => { for (let row = 0; row < flex.rows.length; row++) { for (let col = 0; col < flex.columns.length; col++) { flex.setCellData(row, col, row + col); } } }); } addRowHeader() { this.flex.rowHeaders.columns.push(new wjcGrid.Column()); } removeRowHeader() { let colCnt = this.flex.rowHeaders.columns.length; if (colCnt > 0){ this.flex.rowHeaders.columns.removeAt(colCnt - 1); } } addColumnHeader() { this.flex.columnHeaders.rows.push(new wjcGrid.Row()); } removeColumnHeader() { let rowCnt = this.flex.columnHeaders.rows.length; if (rowCnt > 0){ this.flex.columnHeaders.rows.removeAt(rowCnt - 1); } } } @NgModule({ imports: [WjGridSheetModule, BrowserModule], declarations: [AppComponent], 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 FlexSheet Multiple Headers</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"> <!-- the flexsheet --> <wj-flex-sheet #flex (initialized)="initializeFlexSheet(flex)"> <wj-sheet [name]="'unbound'" [rowCount]="20" [columnCount]="10"></wj-sheet> </wj-flex-sheet> <div class="row well well-lg"> <div class="btn-group"> <button type="button" class="btn btn-default" (click)="addRowHeader()">Add Row Header</button> <button type="button" class="btn btn-default" (click)="removeRowHeader()">Remove Row Header</button> <button type="button" class="btn btn-default" (click)="addColumnHeader()">Add Column Header</button> <button type="button" class="btn btn-default" (click)="removeColumnHeader()">Remove Column Header</button> </div> </div> </div> .wj-flexsheet { height: 400px; margin: 6px 0; } <template> <div class="container-fluid"> <!-- the flexsheet --> <wj-flex-sheet :initialized="initializeFlexSheet"> <wj-sheet :name="'unbound'" :rowCount="20" :columnCount="10"></wj-sheet> </wj-flex-sheet> <div class="row well well-lg"> <div class="btn-group"> <button type="button" class="btn btn-default" @click="addRowHeader">Add Row Header</button> <button type="button" class="btn btn-default" @click="removeRowHeader" >Remove Row Header</button> <button type="button" class="btn btn-default" @click="addColumnHeader" >Add Column Header</button> <button type="button" class="btn btn-default" @click="removeColumnHeader" >Remove Column Header</button> </div> </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.sheet"; import * as wjcGrid from "@grapecity/wijmo.grid"; let App = Vue.extend({ name: "app", data: function() { return { flex: null }; }, methods: { initializeFlexSheet: function(flex) { flex.deferUpdate(() => { for (let row = 0; row < flex.rows.length; row++) { for (let col = 0; col < flex.columns.length; col++) { flex.setCellData(row, col, row + col); } } }); this.flex = flex; }, addRowHeader() { this.flex.rowHeaders.columns.push(new wjcGrid.Column()); }, removeRowHeader() { let colCnt = this.flex.rowHeaders.columns.length; if (colCnt > 0) { this.flex.rowHeaders.columns.removeAt(colCnt - 1); } }, addColumnHeader() { this.flex.columnHeaders.rows.push(new wjcGrid.Row()); }, removeColumnHeader() { let rowCnt = this.flex.columnHeaders.rows.length; if (rowCnt > 0) { this.flex.columnHeaders.rows.removeAt(rowCnt - 1); } } } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> .container-fluid .wj-flexsheet { 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 './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjcGrid from "@grapecity/wijmo.grid"; import * as wjGridSheet from "@grapecity/wijmo.react.grid.sheet"; class App extends React.Component { constructor(props) { super(props); this.state = { flex: null }; } render() { return (<div className="container-fluid"> <wjGridSheet.FlexSheet initialized={this.initializeFlexSheet.bind(this)}> <wjGridSheet.Sheet name="unbound" rowCount={20} columnCount={10}></wjGridSheet.Sheet> </wjGridSheet.FlexSheet> <div className="row well well-lg"> <div className="btn-group"> <button type="button" className="btn btn-default" onClick={this.addRowHeader.bind(this)}>Add Row Header</button> <button type="button" className="btn btn-default" onClick={this.removeRowHeader.bind(this)}>Remove Row Header</button> <button type="button" className="btn btn-default" onClick={this.addColumnHeader.bind(this)}> Add Column Header</button> <button type="button" className="btn btn-default" onClick={this.removeColumnHeader.bind(this)}> Remove Column Header</button> </div> </div> </div>); } initializeFlexSheet(flex) { flex.deferUpdate(() => { for (let row = 0; row < flex.rows.length; row++) { for (let col = 0; col < flex.columns.length; col++) { flex.setCellData(row, col, row + col); } } }); this.setState({ flex: flex }); } addRowHeader() { this.state.flex.rowHeaders.columns.push(new wjcGrid.Column()); this.setState(this.state); } removeRowHeader() { let colCnt = this.state.flex.rowHeaders.columns.length; if (colCnt > 0) { this.state.flex.rowHeaders.columns.removeAt(colCnt - 1); } } addColumnHeader() { this.state.flex.columnHeaders.rows.push(new wjcGrid.Row()); } removeColumnHeader() { let rowCnt = this.state.flex.columnHeaders.rows.length; if (rowCnt > 0) { this.state.flex.columnHeaders.rows.removeAt(rowCnt - 1); } } } 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/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> .container-fluid .wj-flexsheet { height: 400px; margin: 6px 0; }