[]
        
(Showing Draft Content)

GC.Spread.Sheets.Tables.Table

Class: Table

Sheets.Tables.Table

Table of contents

Constructors

Methods

Constructors

constructor

new Table(name?, row?, col?, rowCount?, colCount?, style?)

Represents a table that can be added in a sheet.

Parameters

Name Type Description
name? string The table name.
row? number The table row index.
col? number The table column index.
rowCount? number The table row count.
colCount? number The table column count.
style? TableTheme The table style.

Methods

allowAutoExpand

allowAutoExpand(allowAutoExpandState?): boolean | Table

Gets or sets the allowAutoExpandState of the table.

example

table.allowAutoExpand();
table.allowAutoExpand(true);

Parameters

Name Type
allowAutoExpandState? boolean

Returns

boolean | Table

If there is no allowAutoExpandState set, returns the table allowAutoExpandState; otherwise, returns the table.


autoGenerateColumns

autoGenerateColumns(value?): any

Gets or sets whether to generate columns automatically while binding to a data source.

Parameters

Name Type Description
value? boolean Whether to generate columns automatically while binding to a data source.

Returns

any

If no value is set, returns whether to generate columns automatically while binding to a data source; otherwise, returns the table.


bandColumns

bandColumns(value?): any

Gets or sets a value that indicates whether to display an alternating column style.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.bandColumns(true);
sTable.bandRows(true);

Parameters

Name Type Description
value? boolean Whether to display an alternating column style.

Returns

any

If no value is set, returns whether to display an alternating column style; otherwise, returns the table.


bandRows

bandRows(value?): any

Gets or sets a value that indicates whether to display an alternating row style.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.bandColumns(true);
sTable.bandRows(true);

Parameters

Name Type Description
value? boolean Whether to display an alternating row style.

Returns

any

If no value is set, returns whether to display an alternating row style; otherwise, returns the table.


bind

bind(columns, path?, dataSource?): Table

Gets or sets the dataSource and binding columns and path for the table.

Parameters

Name Type Description
columns TableColumn[] The array of table column information with data fields and names. Each item is GC.Spread.Sheets.Tables.TableColumn.
path? string -
dataSource? object The data source for the table.

Returns

Table

returns the table.


bindColumns

bindColumns(columns): void

Binds the columns using the specified data fields.

Parameters

Name Type Description
columns TableColumn[] The array of table column information with data fields and names. Each item is GC.Spread.Sheets.Tables.TableColumn.

Returns

void


bindingPath

bindingPath(value?): any

Gets or sets the binding path for cell-level binding in the table.

Parameters

Name Type Description
value? string The binding path for cell-level binding in the table.

Returns

any

If no value is set, returns the binding path for cell-level binding in the table; otherwise, returns the table.


clearPendingChanges

clearPendingChanges(): void

Clears the dirty status from the current table.

example

table.clearPendingChanges();

Returns

void


dataRange

dataRange(): Range

Gets the cell range for the table data area.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
var drange = sTable.dataRange();
alert(drange.row);

Returns

Range

The table data range.


deleteColumns

deleteColumns(col, count): void

Delete count number columns in the table at the specified table col index.

example

var table = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
table.deleteColumns(3, 1);

Parameters

Name Type Description
col number The index of the first column to delete, based on table index.
count number The number of columns to delete.

Returns

void


deleteRows

deleteRows(row, count): void

Deletes the rows in this table at the specified table row index.

example

var table = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
table.deleteRows(3, 1);

Parameters

Name Type Description
row number The index of the first row to delete, based on table index.
count number The number of rows to delete.

Returns

void


expandBoundRows

expandBoundRows(value?): any

Gets or sets a value that table expand rows mode in binding case.

example

var spread = GC.Spread.Sheets.findControl("ss") || GC.Spread.Sheets.findControl("sampleDiv");
var sheet = spread.getActiveSheet();
var data = {
    name: 'Jones', region: 'East',
    sales: [
        { orderDate: '1/6/2013', item: 'Pencil', units: 95, cost: 1.99 },
        { orderDate: '4/1/2013', item: 'Binder', units: 60, cost: 4.99 },
        { orderDate: '6/8/2013', item: 'Pen Set', units: 16, cost: 15.99 },
        { orderDate: '8/1/2013', item: 'Pencil', units: 20, cost: 24.99 },
        { orderDate: '10/8/2013', item: 'Binder', units: 31, cost: 16.99 }
    ]
};
var table1 = sheet.tables.add('tableRecords', 0, 0, 4, 4);
var table2 = sheet.tables.add('tableBelow', 4, 0, 4, 7);
table1.bindingPath('sales');
var dataSource = new GC.Spread.Sheets.Bindings.CellBindingSource(data);
table1.expandBoundRows(true);
sheet.setDataSource(dataSource);

Parameters

Name Type Description
value? boolean Whether to expand by sheet or table insert/delete rows.

Returns

any

If no value is set, returns whether to expand by sheet or table insert/delete rows; otherwise, returns the table.


filterButtonVisible

filterButtonVisible(tableColumnIndex?, value?): any

Gets or sets whether the table column's filter button is displayed.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
sTable.bandColumns(true);
sTable.bandRows(true);
sTable.filterButtonVisible(2, false);
alert(sTable.filterButtonVisible(2));

Parameters

Name Type Description
tableColumnIndex? number The table column index of the filter button.
value? boolean Whether the table column's filter button is displayed.

Returns

any

The table column's filter button display state. If no parameter is set, returns false if all filter buttons are invisible, otherwise, true. If only a number is set, returns whether the specified table column' filter button is displayed. If only a boolean that indicates whether to display filter buttons is set, applies to all filter buttons and returns the table. If two parameters are provided, applies to the specified table columns' filter button and returns the table.


footerIndex

footerIndex(): number

Gets the footer index in the sheet.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
sTable.showFooter(true);
sTable.setColumnName(4, "SUM");
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");
var value = sTable.footerIndex();
alert(value);

Returns

number

The footer index.


getColumnFormula

getColumnFormula(tableColumnIndex): string

Gets the table footer formula with the specified index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
sTable.showFooter(true);
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");
var value = sTable.getColumnFormula(4);
alert(value);

Parameters

Name Type Description
tableColumnIndex number The column index of the table footer. The index is zero-based.

Returns

string

The table footer formula.


getColumnName

getColumnName(tableColumnIndex): string

Gets the table header text with the specified table index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
sTable.showFooter(true);
sTable.setColumnName(4, "SUM");
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");
var value = sTable.getColumnName(4);
alert(value);

Parameters

Name Type Description
tableColumnIndex number The column index of the table header. The index is zero-based.

Returns

string

The header text of the specified column by index.


getColumnValue

getColumnValue(tableColumnIndex): string

Gets the table footer value with the specified index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
sTable.showFooter(true);
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");
var value = sTable.getColumnValue(0);
alert(value);

Parameters

Name Type Description
tableColumnIndex number The column index of the table footer. The index is zero-based.

Returns

string

The table footer value.


getDirtyRows

getDirtyRows(): IRowState[]

Get array of dirty rows.

Returns

IRowState[]

The dirty rows collection. The item in array contains three properties, row: specifies table row index, item: specifies data item of current row, originalItem: specifies original data item of the row.


headerIndex

headerIndex(): number

Gets the header index in the sheet.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
var hindex = sTable.headerIndex();
alert(hindex);

Returns

number

The header index.


highlightFirstColumn

highlightFirstColumn(value?): any

Gets or sets a value that indicates whether to highlight the first column.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.highlightFirstColumn(true);
sTable.highlightLastColumn(true);

Parameters

Name Type Description
value? boolean Whether to highlight the first column.

Returns

any

If no value is set, returns whether to highlight the first column; otherwise, returns the table.


highlightLastColumn

highlightLastColumn(value?): any

Gets or sets a value that indicates whether to highlight the last column.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.highlightFirstColumn(true);
sTable.highlightLastColumn(true);

Parameters

Name Type Description
value? boolean Whether to highlight the last column.

Returns

any

If no value is set, returns whether to highlight the last column; otherwise, returns the table.


insertColumns

insertColumns(col, count, isInsertAfter?): void

Insert count number columns in this table before the specified table col index.

example

var table = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
table.insertColumns(3, 1);

Parameters

Name Type Description
col number Column index at which to add the new columns, based on table index.
count number The number of columns to add.
isInsertAfter? boolean Whether insert columns before the specified column index or after. By default, insert before.

Returns

void


insertRows

insertRows(row, count, isInsertAfter?): void

Insert rows in this table before the specified table row index.

example

var table = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
table.insertRows(3, 1);

Parameters

Name Type Description
row number The index of the starting row to insert, based on table index.
count number The number of rows to add.
isInsertAfter? boolean Whether insert rows before the specified row index or after. By default, insert before.

Returns

void


name

name(value?): any

Gets or sets the table name.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
var tname = sTable.name();
alert(tname);

Parameters

Name Type Description
value? string The table name.

Returns

any

If no value is set, returns the table name; otherwise, returns the table.


range

range(): Range

Gets the range for the entire table.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableTheme.medium2);
var drange = sTable.range();
alert(drange.row);

Returns

Range

The whole table range.


rowFilter

rowFilter(): HideRowFilter

Gets the row filter for the table.

Returns

HideRowFilter

The row filter.


setColumnDataFormula

setColumnDataFormula(tableColumnIndex, formula): Table

Sets a formula to the table's data range with the specified index.

example

//This example uses a structured reference formula in the table.
activeSheet.tables.add("Table1", 0, 0, 4, 3, GC.Spread.Sheets.Tables.TableTheme.dark1);
activeSheet.getCell(0,0).text("Value1");
activeSheet.getCell(0,1).text("Value2");
activeSheet.getCell(0,2).text("Total");
activeSheet.getCell(1,0).text("1");
activeSheet.getCell(2,0).text("2");
activeSheet.getCell(3,0).text("3");
activeSheet.getCell(1,1).text("5");
activeSheet.getCell(2,1).text("5");
activeSheet.getCell(3,1).text("5");
activeSheet.tables.findByName("Table1").setColumnDataFormula(2, "=[Value1]*[Value2]");

Parameters

Name Type Description
tableColumnIndex number The column index of the table. The index is zero-based.
formula string The data range formula.

Returns

Table

The table.


setColumnFormula

setColumnFormula(tableColumnIndex, formula): Table

Sets the table footer formula with the specified index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showFooter(true);
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");

Parameters

Name Type Description
tableColumnIndex number The column index of the table footer. The index is zero-based.
formula string The table footer formula.

Returns

Table

The table.


setColumnName

setColumnName(tableColumnIndex, name): Table

Sets the table header text with the specified table index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showFooter(true);
sTable.setColumnName(4, "SUM");
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");

Parameters

Name Type Description
tableColumnIndex number The column index of the table header. The index is zero-based.
name string The header text.

Returns

Table

The table.


setColumnValue

setColumnValue(tableColumnIndex, value): Table

Sets the table footer value with the specified index.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showFooter(true);
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");

Parameters

Name Type Description
tableColumnIndex number The column index of the table footer. The index is zero-based.
value Object The table footer value.

Returns

Table

The table.


showFooter

showFooter(value?, isFooterInserted?): any

Gets or sets a value that indicates whether to display a footer.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showFooter(true);
//set footer value
sTable.setColumnValue(0, "Total");
//set footer formula
sTable.setColumnFormula(4, "SUM(F3:F11)");

Parameters

Name Type Description
value? boolean Whether to display a footer.
isFooterInserted? boolean value decide the way of adding footer, whether insert total row or just override the next row. Remove footer is same.

Returns

any

If no value is set, returns whether to display a footer; otherwise, returns the table.


showHeader

showHeader(value?): any

Gets or sets a value that indicates whether to display a header.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showHeader(true);

Parameters

Name Type Description
value? boolean Whether to display a header.

Returns

any

If no value is set, returns whether to display a header; otherwise, returns the table.


showResizeHandle

showResizeHandle(value?): any

Gets or sets a value that indicates whether to display the resize handle for table.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.showResizeHandle(true);

Parameters

Name Type Description
value? boolean Whether to display the resize handle for table.

Returns

any

If no value is set, returns whether to display the resize handle for table, by default is false; otherwise, returns the table.


style

style(value?): any

Gets or sets a style for the table.

Parameters

Name Type Description
value? TableTheme The style for the table.

Returns

any

If no value is set, returns the table style; otherwise, returns the table.


useFooterDropDownList

useFooterDropDownList(value?): any

Gets or sets a value that indicates whether to use the footer dropdown list for a total row.

example

var sTable = activeSheet.tables.add("table1", 1, 1, 10, 5, GC.Spread.Sheets.Tables.TableThemes.medium2);
sTable.useFooterDropDownList(true);

Parameters

Name Type Description
value? boolean Whether to use the footer dropdown list.

Returns

any

If no value is set, returns whether to use the footer dropdown list for a total row, by default is false; otherwise, returns the table.