DataGridSource class abstract
A datasource for obtaining the row data for the SfDataGrid.
The following APIs are mandatory to process the data,
- rows - The number of rows in a datagrid and row selection depends on the rows. So, set the collection required for datagrid in rows.
- buildRow - The data needed for the cells is obtained from buildRow.
Call the notifyDataSourceListeners when performing CRUD in the underlying datasource.
DataGridSource objects are expected to be long-lived, not recreated with each build.
final List<Employee> _employees = <Employee>[];
class EmployeeDataSource extends DataGridSource {
@override
List<DataGridRow> get rows => _employees
.map<DataGridRow>((dataRow) => DataGridRow(cells: [
DataGridCell<int>(columnName: 'id', value: dataRow.id),
DataGridCell<String>(columnName: 'name', value: dataRow.name),
DataGridCell<String>(
columnName: 'designation', value: dataRow.designation),
DataGridCell<int>(columnName: 'salary', value: dataRow.salary),
]))
.toList();
@override
DataGridRowAdapter? buildRow(DataGridRow row) {
return DataGridRowAdapter(
cells: row.getCells().map<Widget>((dataCell) {
return Text(dataCell.value.toString());
}).toList());
}
}
- Inheritance
-
- Object
- ChangeNotifier
- DataGridSourceChangeNotifier
- DataGridSource
- Mixed-in types
Constructors
Properties
-
effectiveRows
→ List<
DataGridRow> -
Return the copy of the DataGridSource.rows.
It holds the sorted collection if the sorting is applied in DataGrid.
no setter
-
filterConditions
→ Map<
String, List< FilterCondition> > -
Holds the collection of FilterCondition based on the columns.
no setter
-
groupedColumns
→ List<
ColumnGroup> -
The collection of ColumnGroup to be grouped in the SfDataGrid.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
rows
→ List<
DataGridRow> -
The collection of rows to display in SfDataGrid.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sortedColumns
→ List<
SortColumnDetails> -
The collection of SortColumnDetails objects to sort the columns in
SfDataGrid.
no setter
Methods
-
addColumnGroup(
ColumnGroup columnGroup) → void - Call this method to add a specified ColumnGroup to the column grouping.
-
addFilter(
String columnName, FilterCondition filterCondition) → void - Call this method to add the FilterCondition programmatically.
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
buildEditWidget(
DataGridRow dataGridRow, RowColumnIndex rowColumnIndex, GridColumn column, CellSubmit submitCell) → Widget? - Called to obtain the widget when a cell is moved into edit mode.
-
buildGroupCaptionCellWidget(
RowColumnIndex rowColumnIndex, String summaryValue) → Widget? - Called to obtain each cell in the caption summary row.
-
buildRow(
DataGridRow row) → DataGridRowAdapter? - Called to obtain the widget for each cell of the row.
-
buildTableSummaryCellWidget(
GridTableSummaryRow summaryRow, GridSummaryColumn? summaryColumn, RowColumnIndex rowColumnIndex, String summaryValue) → Widget? - Called to obtain the widget for each cell of the table summary row.
-
calculateSummaryValue(
GridTableSummaryRow summaryRow, GridSummaryColumn? summaryColumn, RowColumnIndex rowColumnIndex) → String - Calculates the summary value for the table summary row of a specific column.
-
canSubmitCell(
DataGridRow dataGridRow, RowColumnIndex rowColumnIndex, GridColumn column) → Future< bool> - Called whenever the cell’s editing is completed i.e. prior to onCellSubmit method.
-
clearColumnGroups(
) → void - Clear all the ColumnGroup from the column grouping.
-
clearFilters(
{String? columnName}) → void - Clear the FilterCondition from a given column or clear all the filter conditions from all the columns.
-
compare(
DataGridRow? a, DataGridRow? b, SortColumnDetails sortColumn) → int - Called when the sorting is applied for column. This method compares the two objects and returns the order either they are equal, or one is greater than or lesser than the other.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
handleLoadMoreRows(
) → Future< void> - Called when LoadMoreRows function is called from the SfDataGrid.loadMoreViewBuilder.
-
handlePageChange(
int oldPageIndex, int newPageIndex) → Future< bool> -
Called when the page is navigated.
override
-
handleRefresh(
) → Future< void> -
Called when the
swipe to refresh
is performed in SfDataGrid. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyDataSourceListeners(
{RowColumnIndex? rowColumnIndex}) → void -
Calls all the datagrid source listeners.
Call this method whenever the underlying data is added or removed. If the value of the specific cell is updated, call this method with RowColumnIndex argument where it refers the corresponding row and column index of the cell.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onCellBeginEdit(
DataGridRow dataGridRow, RowColumnIndex rowColumnIndex, GridColumn column) → bool - Called whenever the cell is moved into edit mode.
-
onCellCancelEdit(
DataGridRow dataGridRow, RowColumnIndex rowColumnIndex, GridColumn column) → void - Called when you press the LogicalKeyboardKey.escape key when the DataGridCell on editing to cancel the editing.
-
onCellSubmit(
DataGridRow dataGridRow, RowColumnIndex rowColumnIndex, GridColumn column) → Future< void> - Called whenever the cell’s editing is completed.
-
performGrouping(
String columnName, DataGridRow row) → String -
Called when grouping is applied to the
SfDataGrid.groupedColumns
. -
performSorting(
List< DataGridRow> rows) → Future<void> - Called when the sorting is applied to the column.
-
removeColumnGroup(
ColumnGroup columnGroup) → void - Call this method to remove a specified ColumnGroup from the column grouping.
-
removeFilter(
String columnName, FilterCondition filterCondition) → void - Remove the FilterCondition from the given column.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
shouldRecalculateColumnWidths(
) → bool - Called whenever you call notifyListeners or notifyDataSourceListeners in the DataGridSource class. If you want to recalculate all columns width (may be when underlying data gets changed), return true.
-
sort(
) → Future< void> - Call this method when you are adding the SortColumnDetails programmatically to the DataGridSource.sortedColumns.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → DataGridRow - An indexer to retrieve the data from the underlying datasource. If the sorting is applied, the data will be retrieved from the sorted datasource.