TableSheet Panel

The TableSheet Panel supports showing/hiding and reordering columns of a TableSheet.

A TableSheet has an interactive TableSheet Panel. Create a TableSheet Panel: The constructor of the TableSheet Panel has 4 parameters: Parameter Type Description name string The table sheet panel name. tableSheet GC.Spread.Sheets.TableSheet.TableSheet The table sheet. host HTMLElement The host element. options Object The initialization options. options.showSource GC.Spread.Sheets.TableSheet.ShowSourceOptions How to show a column value. The enum GC.Spread.Sheets.TableSheet.ShowSourceOptions has 4 options. Key Value Description none 0 Doesn't show a column value. field 1 Shows a column value when it is own field or related field. formula 2 Shows a column value when it is calculated field. all 3 Shows a column value, no matter it is own field, related field, or calculated field. Attaching a TableSheet Panel to a TableSheet: Detaching the TableSheet Panel from the TableSheet: Destroying the TableSheet Panel: Find a TableSheet Panel by its host element:
/*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\/demos\//)[0] + 'server/api'; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@grapecity/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$/en/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.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; }