集算表面板

集算表面板支持显示 / 隐藏列和重新排列表单的列。

集算表可以有一个集算表面板。 创建一个集算表面板。 面板的构造函数有4个参数。 参数 类型 描述 name string 面板名称 tableSheet GC.Spread.Sheets.TableSheet.TableSheet 集算表示例 host HTMLElement HTML元素 options Object 初始化选项 options.showSource GC.Spread.Sheets.TableSheet.ShowSourceOptions 如何显示一个列的值 枚举GC.Spread.Sheets.TableSheet.ShowSourceOptions有4个选项。 键 值 描述 none 0 不显示列值。 field 1 当它是自己的字段或相关字段时,显示一个列值。 formula 2 当它是计算字段时显示一个列值。 all 3 无论它是自己的字段,相关字段,还是计算字段,都显示一个列值。 将面板连接到集算表上。 移除面板关联 销毁面板 通过宿主元素查找面板实例
/*REPLACE_MARKER*/ /*DO NOT DELETE THESE COMMENTS*/ window.onload = function() { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 0 }); initSpread(spread); }; function initSpread(spread) { spread.suspendPaint(); spread.options.autoFitType = GC.Spread.Sheets.AutoFitType.cellWithHeader; //init a data manager var baseApiUrl = getBaseApiUrl(); var dataManager = spread.dataManager(); var orderTable = dataManager.addTable("orderTable", { remote: { read: { url: baseApiUrl + "/Order" } } }); var customerTable = dataManager.addTable("customerTable", { remote: { read: { url: baseApiUrl + "/Customer" } } }); dataManager.addRelationship(orderTable, "CustomerId", "customer", customerTable, "Id", "orders"); //init a table sheet var sheet = spread.addSheetTab(0, "TableSheet1", GC.Spread.Sheets.SheetType.tableSheet); sheet.options.allowAddNew = false; //hide new row //bind a view to the table sheet var style = { formatter: 'MM/dd/yyyy' }; var view = orderTable.addView("myView", [ { value: "Id", width: 80 }, { value: "CustomerId", width: 120 }, { value: "ShipName", width: 100 }, { value: "EmployeeId", width: 120 }, { value: "OrderDate", width: 100, style: style }, { value: "RequiredDate", width: 120, style: style }, { value: "ShippedDate", width: 120, style: style }, { value: "ShipVia", width: 80 }, { value: "Freight", width: 80 }, { value: "ShipAddress", width: 120 }, { value: "ShipCity", width: 100 }, { value: "ShipRegion", width: 100 }, { value: "ShipPostalCode", width: 140 }, { value: "ShipState", width: 120 }, { value: "customer", width: 120, isRelationship: true, visible: false }, { value: "customer.Id", width: 120, isRelationship: true, visible: false }, { value: "customer.CompanyName", width: 120, isRelationship: true, visible: false }, { value: "customer.ContactName", width: 120, isRelationship: true, visible: false }, { value: "customer.ContactTitle", width: 120, isRelationship: true, visible: false }, { value: "customer.Address", width: 120, isRelationship: true, visible: false }, { value: "customer.City", width: 120, isRelationship: true, visible: false }, { value: "customer.Region", width: 120, isRelationship: true, visible: false }, { value: "customer.PostalCode", width: 120, isRelationship: true, visible: false }, { value: "customer.State", width: 120, isRelationship: true, visible: false }, { value: "customer.Phone", width: 120, isRelationship: true, visible: false }, ]); view.fetch().then(function() { sheet.setDataView(view); //init a table sheet panel var host = document.getElementById("panel"); var panel = new GC.Spread.Sheets.TableSheet.TableSheetPanel("myPanel", sheet, host); }); spread.resumePaint(); } function getBaseApiUrl() { return window.location.href.match(/http.+spreadjs\/SpreadJSTutorial\//)[0] + 'server/api'; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="zh-cn" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Promise Polyfill for IE, https://www.npmjs.com/package/promise-polyfill --> <script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="ss" class="sample-spreadsheets"></div> <div id="panel" class="container"> </div> </div> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0; } .sample-spreadsheets { width: calc(100% - 303px); height: 100%; overflow: hidden; float: left; } .container { width: 300px; height: 100%; float: left; border: 1px solid lightgrey; }