行高

默认情况下,表格根据字体大小和“wijmo.css”文件中设置为三个像素的默认单元格填充来计算行高。

您可以通过使用CSS为单元格指定不同的填充来轻松更改此默认值。 这是一种很好的方法,因为它适用于所有网格面板中的单元格,并且不需要任何代码。

例如,下面的第一个网格使用默认样式。 第二个将单元格填充增加到八个像素,这使得它更容易在小屏幕的设备上使用:

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(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = []; for (var i = 0; i < 200; i++) { data.push({ id: i, country: countries[i % countries.length], product: products[i % products.length], sales: Math.random() * 10000, expenses: Math.random() * 5000, }); } // // create a grid with default row height var theGrid = new wjGrid.FlexGrid('#theGrid', { itemsSource: data }); // // create a grid with taller rows (see CSS) var theGridTallRows = new wjGrid.FlexGrid('#theGridTallRows', { itemsSource: data }); // } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Row Height</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"> <h3> Default Cell Padding: 3px</h3> <div id="theGrid"> </div> <h3> Custom Cell Padding: 8px</h3> <div id="theGridTallRows"> </div> </div> </body> </html> .wj-flexgrid { max-height: 250px; margin: 10px 0; } #theGridTallRows .wj-flexgrid .wj-cell { padding: 8px; } body { margin-bottom: 20px; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridModule } from '@grapecity/wijmo.angular2.grid'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any; // DataSvc will be passed by derived classes constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } } //\\ @NgModule({ imports: [WjGridModule, 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 FlexGrid Row Height</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"> <h3> Default Cell Padding: 3px</h3> <div id="theGrid"> <wj-flex-grid [itemsSource]="data"></wj-flex-grid> </div> <h3> Custom Cell Padding: 8px</h3> <div id="theGridTallRows"> <wj-flex-grid [itemsSource]="data"></wj-flex-grid> </div> </div> import { Injectable } from '@angular/core'; interface DataItem { id: number; country: string; product: string; comment: string; sales: number; expenses: number; } @Injectable() export class DataService { getData(): DataItem[] { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = []; for (var i = 0; i < 200; i++) { data.push({ id: i, country: countries[i % countries.length], product: products[i % products.length], comment: i % 5 == 0 ? 'This item has a long comment so it will wrap in the cell.' : '', sales: Math.random() * 10000, expenses: Math.random() * 5000, }); } return data; } } .wj-flexgrid { max-height: 250px; margin: 10px 0; } #theGridTallRows .wj-flexgrid .wj-cell { padding: 8px; } body { margin-bottom: 20px; } <template> <div class="container-fluid"> <h3> Default Cell Padding: 3px</h3> <div id="theGrid"> <wj-flex-grid :items-source="data"></wj-flex-grid> </div> <h3> Custom Cell Padding: 8px</h3> <div id="theGridTallRows"> <wj-flex-grid :items-source="data"></wj-flex-grid> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import Vue from "vue"; import "@grapecity/wijmo.vue2.grid"; import { getData } from "./data"; new Vue({ el: "#app", data: function() { return { data: getData() }; } }); </script> <style> .wj-flexgrid { max-height: 250px; margin: 10px 0; } #theGridTallRows .wj-flexgrid .wj-cell { padding: 8px; } body { margin-bottom: 20px; } </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 Height</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> export function getData() { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = []; for (var i = 0; i < 200; i++) { data.push({ id: i, country: countries[i % countries.length], product: products[i % products.length], comment: i % 5 == 0 ? 'This item has a long comment so it will wrap in the cell.' : '', sales: Math.random() * 10000, expenses: Math.random() * 5000, }); } return data; } 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 { getData } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData() }; } render() { return <div className="container-fluid"> <h3> Default Cell Padding: 3px</h3> <div id="theGrid"> <wjcGrid.FlexGrid itemsSource={this.state.data}></wjcGrid.FlexGrid> </div> <h3> Custom Cell Padding: 8px</h3> <div id="theGridTallRows"> <wjcGrid.FlexGrid itemsSource={this.state.data}></wjcGrid.FlexGrid> </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>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 { max-height: 250px; margin: 10px 0; } #theGridTallRows .wj-flexgrid .wj-cell { padding: 8px; } body { margin-bottom: 20px; } export function getData() { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = []; for (var i = 0; i < 200; i++) { data.push({ id: i, country: countries[i % countries.length], product: products[i % products.length], comment: i % 5 == 0 ? 'This item has a long comment so it will wrap in the cell.' : '', sales: Math.random() * 10000, expenses: Math.random() * 5000, }); } return data; }