找回密码
 立即注册

QQ登录

只需一步,快速开始

wss.

初级会员

49

主题

149

帖子

452

积分

初级会员

积分
452

[已处理] 设置首列宽度

wss.
初级会员   /  发表于:2020-8-27 17:52  /   查看:2457  /  回复:1

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

1 个回复

倒序浏览
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-27 18:32:16
沙发
你好,行头列的集合用这句代码可以访问到 theFirstGrid.rowHeaders.columns,

因此可以通过它对列宽进行设置,列数进行调整,参考完整代码:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. import { FlexGrid, Column } from '@grapecity/wijmo.grid';
  5. document.readyState === 'complete' ? init() : window.onload = init;
  6. function init() {
  7.     // generate some random data
  8.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = [];
  9.     for (var i = 0; i < countries.length; i++) {
  10.         data.push({
  11.             country: countries[i],
  12.             downloads: Math.round(Math.random() * 20000),
  13.             sales: Math.random() * 10000,
  14.             expenses: Math.random() * 5000
  15.         });
  16.     }
  17.     // grid with extra fixed column and auto-generated scrollable columns
  18.     var theFirstGrid = new FlexGrid('#theFirstGrid');
  19.     theFirstGrid.rowHeaders.columns[0].width = 200;
  20.     theFirstGrid.rowHeaders.columns.push(new Column()); // extra fixed column
  21.     theFirstGrid.itemsSource = data; // auto-generate scrollable columns
  22.     // grid with no fixed columns and custom scrollable columns
  23.     var theSecondGrid = new FlexGrid('#theSecondGrid');
  24.     theSecondGrid.rowHeaders.columns.splice(0, 1); // no extra columns
  25.     theSecondGrid.autoGenerateColumns = false; // custom scrollable columns
  26.     theSecondGrid.itemsSource = data;
  27.     var cols = theSecondGrid.columns;
  28.     cols.push(new Column({ binding: 'country', header: 'Country' }));
  29.     cols.push(new Column({ binding: 'sales', header: 'Sales' }));
  30.     cols.push(new Column({ binding: 'expenses', header: 'Expenses' }));
  31. }
复制代码


地址:https://demo.grapecity.com.cn/wi ... /Collections/purejs

完整替换app.js即可看到效果

评分

参与人数 1满意度 +5 收起 理由
wss. + 5 很给力!

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部