本帖最后由 ClarkPan 于 2020-2-4 15:36 编辑
背景:
需要实现一个带有层级的下拉填报表格。
思路:
利用分组列与普通组合框单元格结合,来实现既有层级分层又有下拉填报的填报表格。
核心代码:
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
- var sheet = spread.getActiveSheet();
- var combo = new GC.Spread.Sheets.CellTypes.ComboBox();
- combo.items([
- { text: 'Oranges', value: '11k' },
- { text: 'Apples', value: '15k' },
- { text: 'Grape', value: '100k' }]);
- sheet.setCellType(0, 0, combo, GC.Spread.Sheets.SheetArea.viewport);
- sheet.setCellType(1, 0, combo, GC.Spread.Sheets.SheetArea.viewport);
- sheet.setCellType(2, 0, combo, GC.Spread.Sheets.SheetArea.viewport);
- sheet.getCell(0, 0).textIndent(0);
- sheet.getCell(1, 0).textIndent(1);
- sheet.getCell(2, 0).textIndent(2);
- sheet.outlineColumn.options({columnIndex:0});
复制代码 效果如下:
|
|