[{"id":"b66f8b1e-cc14-4e89-9679-abd5687d283d","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"569bb90a-ea68-46c6-96f1-ab151c120714","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5eb52f08-2d1a-4362-9ffc-4871bdc10f3f","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"341dd607-b97d-4d70-bde2-53acda6b6c95","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"05349273-414f-4208-9ea2-c4fc8f4ea2cb","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"86089f76-b778-4d52-821e-6f27de3df613","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b81e4fd6-1fc5-43a0-a258-b6e16a5cbec6","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8aa8ce31-43e4-438e-951f-241608435260","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"37343f41-6ec2-4c7e-b21d-2cc18d5ce1e0","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5915e52f-64f8-4146-b8bd-81bead6324a3","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"836ba889-af9e-460d-a4cc-c24d922795f2","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4ae14b06-bb68-4394-a210-a46b8f028346","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d8f42066-e9dc-4411-bdcf-43b1a203370c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"7ef86f16-b1a0-49f7-9592-612b9be02b25","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b29c7775-a9a4-451e-a1b5-01d19ed5ca5e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"e56f3989-8f81-46af-90fa-a4813eeb976f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"2526c963-f170-45a8-923e-91b0712a9810","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"24575cf0-501a-44f9-8426-c40f8f4b5552","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1a6f8d7f-acd6-42be-8c4f-f464c6218381","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"82b176fd-5cab-498c-909e-8fa7d29c38d8","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1708b3a9-4f37-44a8-8f0e-f9a2d2e5d940","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"c9ac246e-29fb-4bc4-8231-8439795bb590","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"94f2a5c3-2539-436a-af75-23fbbd1a3957","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d99594f4-2d40-4df4-9419-ba2ca6aa3f7f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"fd66e72d-0f10-4f57-9807-6db26290ab2e","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8f344863-503d-4bc3-a594-3815e7d55f5c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"9be82601-de9d-4c18-948a-23ab6f4dd431","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"6495f3c0-b463-47e0-b08a-ca949672211e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b4bede08-3f08-4839-ba4a-abc7ac195bde","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4afcdfc0-3ff5-4f2b-a223-f8fc042a5bbe","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"422062c4-fa40-4771-a86f-008efe6d86e5","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d87e8013-86a7-4840-8d25-6f62e14eb4ac","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a6acedfd-4043-4c64-a5d1-aec3326df9e7","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"dbdc0b24-06c4-48b9-8d6c-7455119dc773","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a3856849-954a-4cfc-96a6-382e530d3638","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4a39306b-ffa5-433d-80a3-28e41f929b72","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]}]
        
(Showing Draft Content)

分组列

SpreadJS中的分组列是指在列中缩进文本以在表单中创建树状结构,以更好地组织数据。

当您要在行之间添加层次结构关系以及表单中的内置扩展和折叠用户界面时,此功能特别有用。 另外,概述列在您需要创建项目计划任务和项目计划子任务层次结构,财务报表和物料单清单的同时,还需要处理表单中的大量数据时会很有帮助。

用户可以概述表单中的列,同时还可以添加复选框和图像以及折叠和展开图标。

下图显示带有折叠和展开图标,复选框,图像和行大纲的分组列。

您可以使用 showRowOutline 方法 来实现表单中的折叠和展开图标。 树结构中的级别对应于缩进的数量。

您还可以使用 outlineColumn.options 按级别自定义图像,显示自定义指示器,显示复选框并设置最大级别。

示例代码

本示例说明如何缩进列以及添加图像和复选框。

var rowCount = 38;
var colCount = 10;
activeSheet.setColumnCount(colCount);
activeSheet.setRowCount(rowCount);
activeSheet.setColumnWidth(0, 310);
activeSheet.setColumnWidth(1, 150);
activeSheet.setColumnWidth(2, 150);
activeSheet.frozenColumnCount(1);
activeSheet.setValue(0, 0, "Name", GC.Spread.Sheets.SheetArea.colHeader);
activeSheet.setValue(0, 1, "Chapter", GC.Spread.Sheets.SheetArea.colHeader);
activeSheet.setValue(0, 2, "Page", GC.Spread.Sheets.SheetArea.colHeader);
var commands = [
{name: 'Preface', chapter: '1', page: 1, indent: 0},
{name: 'Java SE5 and SE6', chapter: '1.1', page: 2, indent: 1},
{name: 'Java SE6', chapter: '1.1.1', page: 2, indent: 2},
{name: 'The 4th edition', chapter: '1.2', page: 2, indent: 1},
{name: 'Changes', chapter: '1.2.1', page: 3, indent: 2},
{name: 'Note on the cover design', chapter: '1.3', page: 4, indent: 1},
{name: 'Acknowledgements', chapter: '1.4', page: 4, indent: 1},
{name: 'Introduction', chapter: '2', page: 9, indent: 0},
{name: 'Prerequisites', chapter: '2.1', page: 9, indent: 1},
{name: 'Learning Java', chapter: '2.2', page: 10, indent: 1},
{name: 'Goals', chapter: '2.3', page: 10, indent: 1},
{name: 'Teaching from this book', chapter: '2.4', page: 11, indent: 1},
{name: 'JDK HTML documentation', chapter: '2.5', page: 11, indent: 1},
{name: 'Exercises', chapter: '2.6', page: 12, indent: 1},
{name: 'Foundations for Java', chapter: '2.7', page: 12, indent: 1},
{name: 'Source code', chapter: '2.8', page: 12, indent: 1},
{name: 'Coding standards', chapter: '2.8.1', page: 14, indent: 2},
{name: 'Errors', chapter: '2.9', page: 14, indent: 1},
{name: 'Introduction to Objects', chapter: '3', page: 15, indent: 0},
{name: 'The progress of abstraction', chapter: '3.1', page: 15, indent: 1},
{name: 'An object has an interface', chapter: '3.2', page: 17, indent: 1},
{name: 'An object provides services', chapter: '3.3', page: 18, indent: 1},
{name: 'The hidden implementation', chapter: '3.4', page: 19, indent: 1},
{name: 'Reusing the implementation', chapter: '3.5', page: 20, indent: 1},
{name: 'Inheritance', chapter: '3.6', page: 21, indent: 1},
{name: 'Is-a vs. is-like-a relationships', chapter: '3.6.1', page: 24, indent: 2},
{name: 'Interchangeable objects with polymorphism', chapter: '3.7', page: 25, indent: 1},
{name: 'The singly rooted hierarchy', chapter: '3.8', page: 28, indent: 1},
{name: 'Containers', chapter: '3.9', page: 28, indent: 1},
{name: 'Parameterized types (Generics)', chapter: '3.10', page: 29, indent: 1},
{name: 'Object creation & lifetime', chapter: '3.11', page: 30, indent: 1},
{name: 'Exception handling: dealing with errors', chapter: '3.12', page: 31, indent: 1},
{name: 'Concurrent programming', chapter: '3.13', page: 32, indent: 1},
{name: 'Java and the Internet', chapter: '3.14', page: 33, indent: 1},
{name: 'What is the Web?', chapter: '3.14.1', page: 33, indent: 2},
{name: 'Client-side programming', chapter: '3.14.2', page: 34, indent: 2},
{name: 'Server-side programming', chapter: '3.14.3', page: 38, indent: 2},
{name: 'Summary', chapter: '3.15', page: 38, indent: 1},
];
for (var r = 0; r < commands.length; r++) {
activeSheet.setValue(r, 0, commands[r]['name']);
activeSheet.setValue(r, 1, commands[r]['chapter']);
activeSheet.setValue(r, 2, commands[r]['page']);
activeSheet.getRange(r, 0, 1, 1).textIndent(commands[r].indent);
}
activeSheet.outlineColumn.options({
columnIndex: 0,
showImage: true,
showCheckBox: true,
images: ['star2.png', 'box4.png', 'rating4.png'],
maxLevel: 2
});
activeSheet.showRowOutline(true);
spread.invalidateLayout();
spread.repaint();

本示例在范围分组中添加和删除分组列。

$("#button1").click(function ()
{
    var activeSheet = spread.getActiveSheet();
    activeSheet.suspendPaint();
   
    // 分组列
    activeSheet.rowOutlines.group(0, 4);
    activeSheet.rowOutlines.group(0, 1);
    activeSheet.rowOutlines.group(2, 1);
   
    // 设置分组列
    activeSheet.columnOutlines.group(0, 4);
    activeSheet.columnOutlines.group(0, 1);
    activeSheet.columnOutlines.group(2, 1);
    activeSheet.resumePaint();
});

$("#button2").click(function()
{
    var activeSheet = spread.getActiveSheet();
    activeSheet.suspendPaint();
   
    // 移除分组
    activeSheet.rowOutlines.ungroupRange(0, 4);
    activeSheet.rowOutlines.ungroupRange(0, 1);
    activeSheet.rowOutlines.ungroupRange(2, 1);
   
    // 移除分组
    activeSheet.columnOutlines.ungroupRange(0, 4);
    activeSheet.columnOutlines.ungroupRange(0, 1);
    activeSheet.columnOutlines.ungroupRange(2, 1);
    activeSheet.resumePaint();
});

本示例展开和折叠分组。

window.onload = function()
{
     var spread =
     new GC.Spread.Sheets.Workbook(document.getElementById("ss"),
     {sheetCount:3});
     var activeSheet = spread.getActiveSheet();
     activeSheet.suspendPaint();

   // 设置分组
   activeSheet.rowOutlines.group(0, 4);
   activeSheet.rowOutlines.group(0, 1);
   activeSheet.rowOutlines.group(2, 1);

   // 设置分组
   activeSheet.columnOutlines.group(0, 4);
   activeSheet.columnOutlines.group(0, 1);
   activeSheet.columnOutlines.group(2, 1);
   activeSheet.resumePaint();

  $("#button1").click(function()
  {
     // 获取行的分组标签数
     var rgl = activeSheet.rowOutlines.getMaxLevel();
     for(var index = 0; index <= rgl; index++)
     {
        //展开分组
        activeSheet.rowOutlines.expand(index, true);
     }
      // 获取列的分组标签数
      var cgl = activeSheet.columnOutlines.getMaxLevel();
      var gi = [];
      var colCount = activeSheet.getColumnCount();
      for(var index = 0, i = 0; index <= cgl; index++)
      {
         for(var col = 0; col < colCount; col++){
         
         // 获取分组信息
         var groupInfo = activeSheet.columnOutlines.find(col, index);
         if(groupInfo)
          {
            gi[i] = groupInfo;
            i++;
            col = groupInfo.end;
           }
       }
   }
   
   for(var i = 0; i < gi.length; i++)
  {         
   // 展开分组
   activeSheet.columnOutlines.expandGroup(gi[i], true);
   }
   activeSheet.invalidateLayout();
   activeSheet.repaint();
  });
    
   $("#button2").click(function()
   { 
     // 获取分组标签数
     var rgl = activeSheet.rowOutlines.getMaxLevel();
     for(var index = 0; index <= rgl; index++){
     
     // 折叠分组
     activeSheet.rowOutlines.expand(index, false);
   }
   
   // 获取分组标签数
   var cgl = activeSheet.columnOutlines.getMaxLevel();
   var gi = [];
   var colCount = activeSheet.getColumnCount();
   for(var index = 0, i = 0; index <= cgl; index++)
   {
     for(var col = 0; col < colCount; col++)
     {
       // 获取分组信息
       var groupInfo = activeSheet.columnOutlines.find(col, index);
       if(groupInfo)
           {
             gi[i] = groupInfo;
             i++;
             col = groupInfo.end;
           }
     }
     }
     
     for(var i = 0; i < gi.length; i++)
     {
        // 折叠分组
        activeSheet.columnOutlines.expandGroup(gi[i], false);
     }
     activeSheet.invalidateLayout();
     activeSheet.repaint();
});
}

注意: 此功能具有以下限制: