buildPlutoRow method

PlutoRow? buildPlutoRow(
  1. int rowIdx
)

Implementation

PlutoRow? buildPlutoRow(int rowIdx) {
  PlutoRow? row;

  // get the data row
  dynamic data = widget.model.getData(rowIdx);

  // create the row
  if (data != null) {
    Map<String, PlutoCell> cells = {};

    // get row model
    for (var column in columns) {

      // get column index
      var colIdx = map.containsKey(column) ? map[column]!.index : -1;

      // get column model
      var model = widget.model.header?.cell(colIdx);

      // simple grid
      dynamic value;

      // get value override from model
      if (model?.usesRenderer == true) {
        value = widget.model.getRowCellModel(rowIdx, colIdx)?.value;
      }

      // get value from data
      value ??= Data.read(data, column.field);

      // null values must be set to a blank string
      // otherwise they show as the word "null" on the grid
      value ??= "";

      // create the cell
      cells[column.field] = PlutoCell(value: value);
      colIdx++;
    }
    row = PlutoRow(cells: cells, sortIdx: rowIdx);
    rows.insert(rowIdx, row);
  }

  return row;
}