grid_fill method
fill sap grid with data
eg. .grid_fill(WithId//('C120', data)
data is a list of maps
will iterate through the list and fill the grid
set element with id "grid#C120#1,2#if" to "data'1,2'"
set element with id "grid#C120#1,3#if" to "data'1,3'"
set element with id "grid#C120#1,6#if" to "data'1,6'"
Implementation
Future<Online> grid_fill(
SelectorBuilder selectorBuilder, List<Map<String, dynamic>> data) async {
for (var rowIndex = 0; rowIndex < data.length; rowIndex++) {
var row = data[rowIndex];
for (var cellKey in row.keys) {
// CellKey is expected to be in the format 'row,column'
var coordinates = cellKey.split(',');
if (coordinates.length != 2) {
continue; // Skip invalid keys
}
var rowIdx = int.tryParse(coordinates[0]);
var colIdx = int.tryParse(coordinates[1]);
if (rowIdx == null || colIdx == null) {
continue; // Skip if indexes are not integers
}
// Build the selector using the provided SelectorBuilder function
var selector = selectorBuilder(rowIdx, colIdx);
var cellValue = row[cellKey];
// Perform the action on the cell, e.g., setting its value
// This assumes `action` is a function that can take a selector and a value
await set(selector, cellValue.toString());
}
}
return this;
}