你好,由于pivotGrid的列比较灵活,理论上是不便于穷举的,所以无法在刚开始就固定设置列宽,您可以参考我的方案,在updatedView事件里加入判断,修改列宽,参考代码:
- 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 wjOlap from '@grapecity/wijmo.olap';
- import { getData } from './data';
- //
- document.readyState === 'complete' ? init() : window.onload = init;
- //
- function init() {
- //
- // initialize pivot engine
- var ng = new wjOlap.PivotEngine({
- itemsSource: getData(1000),
- valueFields: ['Amount'],
- rowFields: ['Buyer', 'Type'],
- showRowTotals: 'Subtotals',
- showColumnTotals: 'Subtotals',
- });
- var amountField = ng.fields.getField('Amount');
- amountField.format = 'c0';
- var dateField = ng.fields.getField('Date');
- dateField.format = 'yyyy'; // show dates as years
- //
- // show pivot grid
- var pivotGrid = new wjOlap.PivotGrid('#pivotGrid', {
- itemsSource: ng,
- updatedView: function(s){
- var cols = s.columns;
- if(cols && cols.length>0){
- cols.forEach(function(col){
- if(col.binding.indexOf("Books")>-1){
- col.width = 500;
- }
- });
- }
- }
- });
- // show pivot panel
- var pivotPanel = new wjOlap.PivotPanel('#pivotPanel', {
- itemsSource: ng
- });
- //
- }
复制代码
这段代码完整拷贝后,完全替换例子中的app.js即可看到效果:
https://demo.grapecity.com.cn/wi ... rid/Overview/purejs |