eachVisibleCoord(action: function, context: Object);
action. Function invoked for each coordinate that corresponds to a visible 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.
The eachVisibleCoord method executes specified function for each coordinate that corresponds to a visible cell in the given range.
To execute the example, the HTML page must contain the TabSheet component named tabSheet (see Example of Creating the TabSheet Component). Set the B1:F3 cell range and select it. Set yellow fill color for all visible cells in the range, and add the character R to values of all visible real cells:
// Determine the B1:F3 range var range = tabSheet.getRange(1, 1, 5, 3); var model = tabSheet.getModel(); // Table model // Select the range range.select(); /* Determine the action to execute for each coordinate that corresponds to the visible cell in the range */ var forEachVisibleCoordFunc = function (coord, args) { // Get table cell var cell = model.getCell(coord); // Get cell style var style = cell.getStyle(); style.Fill.Color = "#FFFACD"; // Yellow fill color cell.setStyle(style); // Set cell style // Set this style for the table cell too var style = model.getStylesJSON()[0]; model.setStyle(tabSheet.getCell(coord.rowIndex, coord.colIndex), style); }; /* Call function of processing coordinates that correspond to visible cells in the range */ range.eachVisibleCoord(forEachVisibleCoordFunc, range); /* Determine the action to execute for each visible real cell in the range */ var forEachVisibleRealCoordFunc = function (cell, args) { // Add the R character to each cell value var value = cell.CellData.FormattedText; var coord = cell.getCoord(); tabSheet.setCellValue(value + "R", coord.rowIndex, coord.colIndex); }; /* Perform the forEachVisibleRealCoordFunc function for all visible real cells in the range*/ range.eachVisibleRealCell(forEachVisibleRealCoordFunc, range); // Scroll the table to the D column tabSheet.scrollToColumn(2);
After executing the example the B1:F3 range is selected, yellow fill color is set for all visible cells in this range, and the character R is added to values of all visible real cells. To make the example more visual, the table is horizontally scrolled to the column D:
See also: