TabSheetRange.eachCell

Syntax

eachCell(action: function, context: Object);

Parameters

action. Function invoked for each cell in the given range.

context. Context from which the method is called. This is an optional parameter, by default it equals to the current context of this.

Description

The eachCell method executes specified function for each cell in the given range.

Example

To execute the example, the HTML page must contain the TabSheet component named tabSheet (see Example of Creating the TabSheet Component). Determine the cell range B1:B2 and select this range. Then change column width and row height in this range, and add the plus sign + to values of all cells in this range:

// Determine the range B1:B2
var range = tabSheet.getRange(1, 1, 1, 2);
// Select the range
range.select();
// Determine the function to perform for each range cell
var forEachFunc = function (context, args) {
    // Add the + sign to each cell value
    var value = tabSheet.getModel().getCell(args).CellData.FormattedText;
    tabSheet.setCellValue("+ " + value, args.rowIndex, args.colIndex);
};
// Perform the forEachFunc function for all range cells
range.eachCell(forEachFunc, range);
// Determine the function to perform for each range column
var forEachColIndexFunc = function (context, args) {
    // Change width of the columns in the specified range
    tabSheet.setColumnWidth(50, args + range.getCorners().tlCoord.colIndex);
};
// Perform the forEachColIndexFunc function for all table columns in the range
range.eachColIndex(forEachColIndexFunc, range, True);
// Determine the function to perform for each range row
var forEachRowIndexFunc = function (context, args) {
    // Change height for each row in the specified range
    tabSheet.setRowHeight(30, args + range.getCorners().tlCoord.rowIndex);
};
// Perform the forEachRowIndexFunc function for all rows in the range
range.eachRowIndex(forEachRowIndexFunc, range, True);

After executing the example the cell range B1:B2 is selected, columns width and rows height in the range is changed, and the plus sign + is added to values of all the cells in this range:

See also:

TabSheetRange