找回密码
 立即注册

QQ登录

只需一步,快速开始

wss.

初级会员

49

主题

149

帖子

452

积分

初级会员

积分
452

[已处理] 表头自适应高度

wss.
初级会员   /  发表于:2020-6-12 17:08  /   查看:11890  /  回复:27
1金币

我在列上设置了wordWrap=true; 内容的确自动换行了,但是高度却没变
附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

你好,感谢反馈,本帖就结贴了,新的问题欢迎发新帖交流~

27 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-12 17:08:49
来自 9#
你好,感谢反馈,本帖就结贴了,新的问题欢迎发新帖交流~
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-12 18:20:42
2#
请参考这篇示例:

http://jsfiddle.net/Wijmo5/apzwy85z/

关键代码如下:

  1.     $scope.itemsSourceChanged = function(s, e) {
  2.         setTimeout(function() {
  3.             
  4.             // enable wrapping on first header row
  5.             var row = s.columnHeaders.rows[0];
  6.             row.wordWrap = true;

  7.             // autosize first header row
  8.             s.autoSizeRow(0, true);
  9.             
  10.             // limit height to 100px
  11.             //if (row.height > 100) {
  12.             //    row.height = 100;
  13.             //}
  14.         });
  15.     }
复制代码
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-13 10:58:26
3#
KevinChen 发表于 2020-6-12 18:20
请参考这篇示例:

http://jsfiddle.net/Wijmo5/apzwy85z/

你好,页面打不开
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-15 09:28:45
4#
你好,请将以下代码完整复制,到示例页面替换掉app.js,点击运行即可看到效果:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import { SortDescription, format } from '@grapecity/wijmo';
  4. import { FlexGrid } from '@grapecity/wijmo.grid';
  5. document.readyState === 'complete' ? init() : window.onload = init;
  6. function init() {
  7.     // create some random data
  8.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
  9.     var data = [];
  10.     for (var i = 0; i < countries.length; i++) {
  11.         data.push({
  12.             id: i,
  13.             country: countries[i],
  14.             sales: Math.random() * 10000,
  15.             expenses: Math.random() * 5000
  16.         });
  17.     }

  18.     var autoFitColumnHeaderWidth = function(s,e){
  19.         setTimeout(function() {
  20.             // enable wrapping on first header row
  21.             var row = s.columnHeaders.rows[0];
  22.             row.wordWrap = true;
  23.             // autosize first header row
  24.             s.autoSizeRow(0, true);
  25.         });
  26.     }

  27.     // bind a grid to the raw data
  28.     var theGrid = new FlexGrid('#theGrid', {
  29.         allowSorting: false,
  30.         showSort: false,
  31.         autoGenerateColumns: false,
  32.         columns: [
  33.             { binding: 'country', header: 'This is the Country column, but the heading is ridiculously wide so we have to wrap...', width: '2*' },
  34.             { binding: 'sales', header: 'Sales', width: '*', format: 'n2' },
  35.             { binding: 'expenses', header: 'Expenses', width: '*', format: 'n2' }
  36.         ],
  37.         itemsSource: data,
  38.         resizedColumn: autoFitColumnHeaderWidth,
  39.         loadedRows: autoFitColumnHeaderWidth
  40.     });
  41.     // show the current item
  42.     var selItemElement = document.getElementById('selectedItem');
  43.     function updateCurrentInfo() {
  44.         selItemElement.innerHTML = format('Country: <b>{country}</b>, Sales: <b>{sales:c0}</b> Expenses: <b>{expenses:c0}</b>', theGrid.collectionView.currentItem);
  45.     }
  46.     // update current item now and when the grid selection changes
  47.     updateCurrentInfo();
  48.     theGrid.collectionView.currentChanged.addHandler(updateCurrentInfo);
  49.     // sort the data by country
  50.     var sd = new SortDescription('country', true);
  51.     theGrid.collectionView.sortDescriptions.push(sd);
  52. }
复制代码


示例地址:

https://demo.grapecity.com.cn/wi ... nding/Basics/purejs
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-16 15:09:02
5#
KevinChen 发表于 2020-6-15 09:28
你好,请将以下代码完整复制,到示例页面替换掉app.js,点击运行即可看到效果:

能否做到单行的话垂直居中呢

本帖子中包含更多资源

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

x
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-16 16:46:53
6#
KevinChen 发表于 2020-6-15 09:28
你好,请将以下代码完整复制,到示例页面替换掉app.js,点击运行即可看到效果:

而且我发现了一个问题,好像这个方法对自定义编辑事件产生了影响(不能编辑)
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-16 16:51:09
7#
本帖最后由 wss. 于 2020-6-16 17:32 编辑
wss. 发表于 2020-6-16 16:46
而且我发现了一个问题,好像这个方法对自定义编辑事件产生了影响(不能编辑)

准确的说loadedRows是这个导致了这个问题,进不来beginningEdit事件

本帖子中包含更多资源

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

x
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-16 18:17:33
8#
KevinChen 发表于 2020-6-15 09:28
你好,请将以下代码完整复制,到示例页面替换掉app.js,点击运行即可看到效果:

打扰了打扰了,我知道问题了
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-6-17 09:28:50
10#
KevinChen 发表于 2020-6-16 18:28
你好,感谢反馈,本帖就结贴了,新的问题欢迎发新帖交流~

不好意思,
楼上这个问题还没解决:
能否做到单行的话垂直居中呢
回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部