DataControl

DataControl is FlexCore's data-aware tabular component. It is inspired by pandas DataFrame and PowerBuilder DataWindow: one in-memory table surface that can feed GridControl, ChartControl, ReportWriterControl, and future data-aware controls.

Live Frame

Shape 4 rows x 4 columns
Size 16 cells
Empty False
Ndim 2
IndexOrderCustomerAmountOpen
row-aA100Acme1280.50true
row-bA101Northwind845.25false
row-cA102Contoso2210.00true
row-dA103Fabrikam1640.75true

Constructor

The pandas-style constructor accepts heterogeneous input and optional axis labels. C# uses PascalCase elsewhere, but this signature maps directly to DataFrame(data=None, index=None, columns=None, dtype=None, copy=None).

var frame = new DataControl(
    data: new Dictionary<string, object?>
    {
        ["Order"] = new[] { "A100", "A101", "A102" },
        ["Customer"] = new[] { "Acme", "Northwind", "Contoso" },
        ["Amount"] = new object?[] { "1280.50", "845.25", "2210.00" }
    },
    index: new[] { "row-a", "row-b", "row-c" },
    columns: new[] { "Order", "Customer", "Amount" });

Metadata

Index

Current row labels, defaulting to range-style labels when no index is supplied.

Columns

Column descriptors: name, caption, data type, nullability, readonly state, and ordinal.

Dtypes

Dictionary of column name to CLR type.

Info

Summary object containing table name, row count, column count, columns, and locale.

Values

Two-dimensional object array of visible values.

Axes

Two axes: row labels and column labels.

Ndim

Always 2 for this tabular control.

Size

Total visible cell count: rows times columns.

Shape

Rows and columns as a DataControlShape record.

Empty

True when there are no rows or no columns.

At

Label-based scalar accessor.

Iat

Position-based scalar accessor.

Typed Access

At reads or writes a scalar by row label and column name. Iat reads or writes by zero-based row and column position.

var amount = frame.At["row-a", "Amount"];
frame.At["row-a", "Amount"] = 1300.00m;

var firstCustomer = frame.Iat[0, 1];
frame.Iat[0, 1] = "Acme Industries";

Dtypes

ConvertDtypes and InferObjects create converted frames. Astype forces one or more columns to a requested CLR type.

Column Original dtype After ConvertDtypes
Order string string
Customer string string
Amount string decimal
Open string bool
var converted = frame.ConvertDtypes();
var decimals = frame.Astype("Amount", typeof(decimal));
var numericOnly = frame.SelectDtypes(include: new[] { typeof(decimal), typeof(int) });

Chart Adapter

ToChartBars and ToChartSeries project the same data into shapes already accepted by ChartControl.

Order Amounts
A100
$1,280
A101
$845
A102
$2,210
A103
$1,641

DataFrame Methods

Head(count)

Returns the first rows as a new DataControl.

Tail(count)

Returns the last rows as a new DataControl.

SelectColumns(...)

Keeps only the requested columns.

DropColumns(...)

Removes requested columns from a copied frame.

RenameColumn(oldName, newName)

Renames a column on the current frame.

AddColumn(name, type, defaultValue)

Adds a typed column and initializes existing rows.

DropNulls(...)

Removes rows with null values in selected columns.

FillNulls(value, ...)

Replaces nulls in selected columns.

Query(expression)

Filters with a DataTable expression and returns a new frame.

Where(predicate)

Filters with a DataRow predicate and returns a new frame.

SortBy(column, descending)

Applies a DataView sort expression.

GroupBy(groupColumn, valueColumn, aggregate)

Groups rows and computes Count, Sum, Average, Min, or Max.

SelectDtypes(include, exclude)

Returns columns matching included and excluded CLR types.

Astype(...)

Returns a frame with one, many, or all columns converted to requested types.

ConvertDtypes()

Infers better CLR types from object or string columns.

InferObjects()

Infers object-backed columns without converting existing string columns.

Copy(deep)

Creates a copied DataControl; deep copy duplicates the table.

DataWindow Methods

RetrieveAsync(...)

Loads a DataTable from a host-provided async retrieval function.

SetData(table)

Replaces the underlying table.

Reset()

Clears data and selection.

ResetUpdate()

Accepts changes and clears dirty state.

GetChanges()

Returns changed rows as a DataTable.

RejectChanges()

Rolls back pending changes.

GetRow() / SetRow(...)

Reads or sets the current 1-based row.

GetItem(...)

Reads a cell by 1-based row and column name.

SetItem(...)

Writes a cell by 1-based row and column name.

InsertRow(...)

Inserts a row with optional values.

DeleteRow(...)

Deletes a row by 1-based row number.

RowsCopy(...)

Copies a row range to another DataControl.

RowsMove(...)

Moves a row range to another DataControl.

RowsDiscard(...)

Removes a row range.

SelectRow(...) / ClearSelection()

Manages selected row numbers.

SelectedData()

Exports selected rows as a DataTable.

Describe(expression)

Reads simple metadata and DataWindow-style properties.

Modify(property, value)

Sets supported DataWindow-style properties.

Find(expression, startRow, endRow)

Finds the first row matching a DataTable expression.

SaveAs(format)

Exports to CSV or JSON text.

Control Adapters

ToGridRows()

Projects visible rows as ExpandoObject instances for dynamic grid binding.

ToDictionaries()

Projects rows as dictionaries keyed by column name.

ToExpandoRows()

Projects rows as dynamic ExpandoObject records.

ToChartSeries(labelColumn, valueColumns)

Builds multi-series chart data.

ToChartBars(labelColumn, valueColumn, colorColumn)

Builds legacy ChartControl bar data.

ToReportColumns()

Creates ReportColumn definitions from the schema.

ToReportDefinition(title)

Creates a basic ReportDefinition from the current schema.

ToJson()

Serializes visible rows as JSON.

ToCsv()

Serializes visible rows as CSV.

Support Types

  • DataControlColumn
  • DataControlInfo
  • DataControlShape
  • DataControlAtIndexer
  • DataControlIatIndexer
  • DataControlAggregateResult
  • DataControlRowChangedEventArgs
  • DataControlAggregate
  • DataControlSaveFormat
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.