找回密码
 立即注册

QQ登录

只需一步,快速开始

美的人都早起

注册会员

10

主题

27

帖子

161

积分

注册会员

积分
161
美的人都早起
注册会员   /  发表于:2021-9-14 09:14  /   查看:2352  /  回复:5
image.png464062194.png
动态绑定表头出现图片中的问题
详细描述
表头根据数据表类型改变,切换不同数据后出现表体重复表头的现象


5 个回复

倒序浏览
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-9-14 10:23:03
沙发
您好,请问您用的数哪种类型的数据绑定呢?下面是学习指南的表格绑定的链接,您可以参考如何进行切换数据,若仍未解决您的问题,麻烦您在附件中复现您的问题,这边调研一下。
https://demo.grapecity.com.cn/spreadjs/SpreadJSTutorial/features/data-binding/table-binding/purejs

online.html

1.46 KB, 下载次数: 147

回复 使用道具 举报
美的人都早起
注册会员   /  发表于:2021-9-15 09:08:43
板凳
Derrick.Jiao 发表于 2021-9-14 10:23
您好,请问您用的数哪种类型的数据绑定呢?下面是学习指南的表格绑定的链接,您可以参考如何进行切换数据, ...
  1. <head>
  2.     <meta charset="UTF-8" />
  3.     <link
  4.         rel="stylesheet" type="text/css" />

  5.     <script src="http://cdn.grapecity.com/spreadjs/hosted/scripts/gc.spread.sheets.all.14.1.6.min.js"></script>
  6.     <script src="http://cdn.grapecity.com/spreadjs/hosted/scripts/interop/gc.spread.excelio.14.1.6.min.js"></script>
  7.     <script src="https://cdn.grapecity.com.cn/spreadjs/scripts/jquery-1.11.1.min.js" type="text/javascript"></script>

  8.     <style>
  9.         .sample-tutorial {
  10.             position: relative;
  11.             height: 100%;
  12.             overflow: hidden;
  13.         }

  14.         .sample-spreadsheets {
  15.             width: calc(100% - 280px);
  16.             height: 100%;
  17.             overflow: hidden;
  18.             float: left;
  19.             position: relative;
  20.         }

  21.         .gc-tab-hover {
  22.             color: red;
  23.             background-image: none;
  24.             background-color: transparent;
  25.             border-style: solid;
  26.             border-left-color: #ababab;
  27.             border-bottom-color: #217346;
  28.         }
  29.     </style>
  30. </head>

  31. <body>

  32.     <div id="ss" class="sample-spreadsheets"></div>
  33.     <button id="change" onclick="changeData()">切换按钮</button>


  34.     <script>

  35.         var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 });
  36.         var sheet = spread.getActiveSheet();
  37.                 var colA = [
  38.                     { name: "id", displayName: "ID" },
  39.                     { name: "name", displayName: "Name", size: 100 },
  40.                     { name: "line", displayName: "Line", size: 80 },
  41.                     { name: "color", displayName: "Color" },
  42.                     { name: "price", displayName: "Price", formatter: "0.00", size: 80 ,addSpan:2,spanTitle:"信息"},
  43.                     { name: "cost", displayName: "Cost", formatter: "0.00", size: 80 },
  44.                     { name: "weight", displayName: "Weight", formatter: "0.00", size: 80 },
  45.                     { name: "discontinued", displayName: "Discontinued", cellType: new GC.Spread.Sheets.CellTypes.CheckBox(), size: 100 },
  46.                     { name: "rating", displayName: "Rating" }
  47.                 ];
  48.                 var colB = [
  49.                     { name: "id", displayName: "ID" },
  50.                     { name: "name", displayName: "Name", size: 100 },
  51.                     { name: "a", displayName: "a", size: 100 },
  52.                     { name: "b", displayName: "b", size: 100 },
  53.                     { name: "c", displayName: "c", size: 100 },
  54.                     { name: "line", displayName: "Line", size: 80 },
  55.                     { name: "color", displayName: "Color" },
  56.                     { name: "price", displayName: "Price", formatter: "0.00", size: 80 ,addSpan:2,spanTitle:"信息"},
  57.                     { name: "cost", displayName: "Cost", formatter: "0.00", size: 80 },
  58.                     { name: "weight", displayName: "Weight", formatter: "0.00", size: 80 },
  59.                     { name: "discontinued", displayName: "Discontinued", cellType: new GC.Spread.Sheets.CellTypes.CheckBox(), size: 100 },
  60.                     { name: "rating", displayName: "Rating" }
  61.                 ];
  62.                 var dataA = [
  63.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  64.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  65.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  66.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  67.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  68.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  69.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  70.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  71.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  72.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  73.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  74.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  75.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  76.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  77.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  78.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:''},
  79.                 ];
  80.                 var dataB = [
  81.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  82.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  83.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  84.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  85.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  86.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  87.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  88.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  89.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  90.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  91.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  92.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  93.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  94.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  95.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  96.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  97.                 {id:'1',name:'1',line:'1',color:'1',price:'1',cost:'1',weight:'1',discontinued:'1',rating:'',a:'',b:'',c:''},
  98.                 ];
  99.                  sheet.setDataSource(dataA);
  100.                   sheet.bindColumns(colA);
  101.                   sheet.setRowCount(2, GC.Spread.Sheets.SheetArea.colHeader);
  102.                           colA.forEach((item, index) => {
  103.                                                         if(!!(item.addSpan)){
  104.                                                           sheet.addSpan(0, index, 2, item.span, GC.Spread.Sheets.SheetArea.colHeader);
  105.                                                           sheet.setValue(0, index, item.spanTitle, GC.Spread.Sheets.SheetArea.colHeader);
  106.                                                           sheet.setValue(1, index, item.displayName, GC.Spread.Sheets.SheetArea.colHeader);
  107.                                                           sheet.setValue(1, index + 1, colA[index + 1].displayName, GC.Spread.Sheets.SheetArea.colHeader);
  108.                                                         }

  109.                                                   })
  110.        function changeData(){
  111.                   sheet.setDataSource(dataB);
  112.                   sheet.bindColumns(colB);
  113.                   sheet.setRowCount(2, GC.Spread.Sheets.SheetArea.colHeader);
  114.                   colB.forEach((item, index) => {
  115.                         if(!!(item.addSpan)){
  116.                           sheet.addSpan(0, index, 2, item.span, GC.Spread.Sheets.SheetArea.colHeader);
  117.                           sheet.setValue(0, index, item.spanTitle, GC.Spread.Sheets.SheetArea.colHeader);
  118.                           sheet.setValue(1, index, item.displayName, GC.Spread.Sheets.SheetArea.colHeader);
  119.                           sheet.setValue(1, index + 1, colB[index + 1].displayName, GC.Spread.Sheets.SheetArea.colHeader);
  120.                         }

  121.                   })
  122.            }
  123.           
  124.   
  125.     </script>
  126. </body>

  127. </html>
复制代码
image.png529895019.png
回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-9-15 09:49:14
地板

请参考这个demo,在重新setDataSource前将原先设置的合并与单元格值清除。
image.png227408446.png

export.html

9.26 KB, 下载次数: 142

回复 使用道具 举报
夏雪冬阳
银牌会员   /  发表于:2023-5-13 12:03:23
5#
这是活字格中的表格吗
回复 使用道具 举报
JoestarXu
超级版主   /  发表于:2023-5-15 11:10:14
6#
夏雪冬阳 发表于 2023-5-13 12:03
这是活字格中的表格吗

您好,活字格中的表格属于SpreadJS的定制版。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部