找回密码
 立即注册

QQ登录

只需一步,快速开始

Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-7-19 14:25:02
10#
美的人都早起 发表于 2021-7-19 14:20
let table = sheet.tables.all()[0];
这一步获取的是undefined

从您的代码中这边没有看到初始化表格的代码,您需要先add再修改才有效,请在此demo上复现您的问题。

SpreadDemo导出.zip

2.89 MB, 下载次数: 79

回复 使用道具 举报
美的人都早起
注册会员   /  发表于:2021-7-19 14:33:34
11#


美的人都早起
注册会员   /  发表于:14 分钟前8#
Derrick.Jiao 发表于 2021-7-19 14:08
请提供一份完整的demo,这边给您调试吧

let arr=[{
amount: 1
chapter: ""
children: undefined
code: "0101-01-01"
comment: null
contractListId: null
createdAt: "2021-07-19 10:58:55"
createdBy: null
deviceCode: "ff"
deviceName: ""
deviceType: ""
deviceUnit: ""
itemMetaId: 12
measureUnit: ""
name: ""
parentCode: "0101-01"
price: 500
secondCode: ""
section: ""
sumList: null
type: "DEVICE"
updatedAt: "2021-07-19 10:58:55"
updatedBy: null
worth: null
}];
let columnList=[{
{name:'itemMetaId', displayName:'', size:0},
          {name:'code',displayName:'清单标号',size:150,formatter:'0'},
          {name:'secondCode',displayName:'清单编码',size:150,formatter:'0'},
          {name:'chapter',displayName:'章',size:30,formatter:'0'},
          {name:'section',displayName:'节',size:30,formatter:'0'},
          {name:'name',displayName:'名称',size:200,formatter:'0'},
}]
let spread= this.spread
sheet = this.spread.getSheet(0);
let that = this;
sheet.autoGenerateColumns = true;
sheet.setDataSource(arr);
sheet.bindColumns(columnList);
//锁定所有单元格
           let tableStyle = new GC.Spread.Sheets.Tables.TableTheme(); let thinBorder = new GC.Spread.Sheets.LineBorder("#d3d6db", GC.Spread.Sheets.LineStyle.thin);
tableStyle.wholeTableStyle(new GC.Spread.Sheets.Tables.TableStyle("#f5f7fa", "#666", "normal 10pt arial", thinBorder, thinBorder, thinBorder, thinBorder, thinBorder, thinBorder));
sheet.tables.add("table", 0, 0, arr.length, that.columnList.length, tableStyle);
            sheet.options.protectionOptions = {
              allowSelectLockedCells: true,
              allowSelectUnlockedCells: true,
              allowFilter: true,
              allowSort: true,
              allowResizeRows: true,
              allowResizeColumns: true,
              allowEditObjects: false,
              allowDragInsertRows: false,
              allowDragInsertColumns: false,
              allowInsertRows: false,
              allowInsertColumns: false,
              allowDeleteRows: false,
              allowDeleteColumns: false,
              allowOutlineColumns: false,
              allowOutlineRows: false
            };
            sheet.options.isProtected = true;
回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-7-19 14:45:28
12#
美的人都早起 发表于 2021-7-19 14:33
美的人都早起
注册会员   /  发表于:14 分钟前8#
Derrick.Jiao 发表于 2021-7-19 14:08

不是很理解你代码中的写法,代码中你用了表单级别绑定,然后又重新添加了一个table,请问你的需求是什么呢?我这边测试将你提供的代码放到下面的demo中未能复现你的问题

SpreadDemo导出.zip

3.5 MB, 下载次数: 94

回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-7-19 14:53:12
14#
美的人都早起 发表于 2021-7-19 14:46
我的代码放到例子里没有报错
sheet.tables.add("dataTable", 0, 0, arr.length, that.columnList.lengt ...

解决了就好,有新问题欢迎开新帖交流~
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 立即注册
返回顶部