eachCoord(action: function, context: Object);
action. Function invoked for each coordinate that corresponds to a 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 eachCoord method executes specified function for each coordinate that corresponds to a 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). Determine the cell range B1:B2 and select this range. Then add the minus sign - to values of all its cells, and change fill color of real cells to yellow:
// Determine the B1:B2 range var range = tabSheet.getRange(1, 1, 1, 2); var model = tabSheet.getModel(); // Table model // Select the range range.select(); /* Determine the function to perform for each coordinate in the range */ var forEachCoordFunc = function (coord, args) { // Add the - sign for each cell var value = tabSheet.getModel().getCell(coord).CellData.FormattedText; tabSheet.setCellValue("-" + value, coord.rowIndex, coord.colIndex); }; /* Perform the forEachCoordFunc function for each coordinate in the range */ range.eachCoord(forEachCoordFunc, range); /* Determine the function to perform for all real range cells */ var forEachRealCellFunction = function (cell, args) { // 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]; var coord = cell.getCoord(); model.setStyle(tabSheet.getCell(coord.rowIndex, coord.colIndex), style); }; /* Perform the forEachRealCellFunction function for all real range cells */ range.eachRealCell(forEachRealCellFunction, range);
After executing the example the range B1:B2 is selected, the minus sign - is added to values of all its cells, and yellow fill color is set for real cells:
See also: