行集合

FlexGrid控件有三组行:

  • 标题行此集合包含顶行;它由 topLeftCellscolumnHeaders 面板使用。默认情况下,此集合包含一行。
  • 可滚动行此集合包含主要行集;它由 单元rowHeaders 面板使用。默认情况下,此集合不包含任何行。设置网格的 itemsSource 属性时会填充它。
  • 页脚行此集合包含最下面的行集;它由 bottomLeftCellscolumnFooters 面板使用。默认情况下,此集合为空。

三个行集合是 RowCollection 对象,它们扩展了常规数组。您可以通过添加或删除这些数组中的 Row 对象来添加或删除行。但是,在大多数情况下,您不会添加或删除可滚动行,因为当您设置 itemsSource 属性时,网格会自动执行此操作。

例如,下面的网格有一个额外的固定行,自动生成的可滚动行和一个页脚行:

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjGrid from '@grapecity/wijmo.grid'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // // generate some random data var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (var i = 0; i < countries.length; i++) { data.push({ country: countries[i], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } // // grid with extra fixed row and a footer row var theGrid = new wjGrid.FlexGrid('#theGrid'); theGrid.columnHeaders.rows.push(new wjGrid.Row()); // add a header row theGrid.columnFooters.rows.push(new wjGrid.Row()); // add a footer row theGrid.bottomLeftCells.setCellData(0, 0, 'x'); // show some data on the first cell theGrid.itemsSource = data; // bind the grid } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Row Collections</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="theGrid"></div> </div> </body> </html> .wj-flexgrid { height: 200px; margin: 10px 0; } body { margin-bottom: 20pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import * as wjcGrid from '@grapecity/wijmo.grid'; import { WjGridModule } from '@grapecity/wijmo.angular2.grid'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; // DataSvc will be passed by derived classes constructor() { this.data = this._getData(); } initializeGrid(flex: wjcGrid.FlexGrid) { flex.columnHeaders.rows.push(new wjcGrid.Row()); // add a header row flex.columnFooters.rows.push(new wjcGrid.Row()); // add a footer row flex.bottomLeftCells.setCellData(0, 0, 'x'); // show some data on the first cell } private _getData() { // generate some random data let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (let i = 0; i < 200; i++) { data.push({ country: countries[i % countries.length], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; } } // @NgModule({ imports: [WjGridModule, 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 FlexGrid Row Collections</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-flex-grid #flex (initialized)="initializeGrid(flex)" [(itemsSource)]="data"> </wj-flex-grid> </div> .wj-flexgrid { height: 200px; margin: 10px 0; } body { margin-bottom: 20pt; } <template> <div class="container-fluid"> <wj-flex-grid :initialized="initializeGrid" :itemsSource="grid.data"> </wj-flex-grid> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import 'bootstrap.css'; import Vue from 'vue'; import * as wjcGrid from '@grapecity/wijmo.grid'; import '@grapecity/wijmo.vue2.grid'; let App = Vue.extend({ name: 'app', data: function(){ let url = 'https://services.odata.org/Northwind/Northwind.svc'; return { grid: { data: null } } }, methods: { initializeGrid: function(flex) { this.grid.data = this.getData(); flex.columnHeaders.rows.push(new wjcGrid.Row()); // add a header row flex.columnFooters.rows.push(new wjcGrid.Row()); // add a footer row flex.bottomLeftCells.setCellData(0, 0, 'x'); // show some data on the first cell }, getData: function() { // generate some random data let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (let i = 0; i < 200; i++) { data.push({ country: countries[i % countries.length], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; } } }) new Vue({ render: h => h(App) }).$mount('#app'); </script> <style> .wj-flexgrid { height: 200px; margin: 10px 0; } body { margin-bottom: 20pt; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Row Collections</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.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import "./app.css"; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjcGrid from "@grapecity/wijmo.react.grid"; import * as wjGrid from "@grapecity/wijmo.grid"; class App extends React.Component { constructor(props) { super(props); this.state = { grid: { data: null } }; } render() { return <div className="container-fluid"> <wjcGrid.FlexGrid initialized={this.initializeGrid.bind(this)} itemsSource={this.state.grid.data}> </wjcGrid.FlexGrid> </div>; } initializeGrid(flex) { this.setState({ grid: { data: this.getData() } }); flex.columnHeaders.rows.push(new wjGrid.Row()); // add a header row flex.columnFooters.rows.push(new wjGrid.Row()); // add a footer row flex.bottomLeftCells.setCellData(0, 0, 'x'); // show some data on the first cell } getData() { // generate some random data let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (let i = 0; i < 200; i++) { data.push({ country: countries[i % countries.length], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; } } 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>Grapecity Wijmo OLAP Pivot Chart Overview</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> .wj-flexgrid { height: 200px; margin: 10px 0; } body { margin-bottom: 20pt; }