updateData method

void updateData(
  1. List<Map<String, dynamic>> newRows
)

Update data (refresh with new rows)

Implementation

void updateData(List<Map<String, dynamic>> newRows) {
  // Reprocess everything with new data
  final processedData = _processTableData(newRows, config.totals);
  final isTreeData = _isTreeData(processedData.regularRows);

  final treeRows = isTreeData
      ? [
          // Prepend total rows as leaf nodes
          ...processedData.totalRows.asMap().entries.map((entry) {
            return TreeRow(
              data: entry.value,
              depth: 0,
              hasChildren: false,
              id: '_total_${entry.key}',
            );
          }),
          ..._treeManager.flattenTree(
            rows: processedData.regularRows,
            expandedIds: _state.expandedRowIds,
          ),
        ]
      : <TreeRow>[];

  final visibleRows = [...processedData.totalRows, ...processedData.regularRows];

  _state = _state.copyWith(
    originalRows: newRows,
    totalRows: processedData.totalRows,
    regularRows: processedData.regularRows,
    visibleRows: visibleRows,
    totalRowCount: visibleRows.length,
    isTreeData: isTreeData,
    treeRows: treeRows,
    loadedRowCount: 50,
  );

  // Re-apply filters if any
  if (_state.columnFilters.isNotEmpty || _state.globalSearchQuery != null) {
    _state = _filterManager.applyFilters(currentState: _state);
  }

  notifyListeners();
}