
Excel-DataTable
Commonly used for large data sheet maintenance
Make the component render like Excel
by setting the table's IsExcel
property
Demo
When the binding is dynamic type in Excel
mode, TableColumn
cannot be used to set column properties. In this example is used DynamicContext
Instance object DataTableDynamicContext
constructor to set
Set the column Items
value, and render the enum type into a Select
component
Demo
DataTableDynamicContext = new(UserData, (context, col) =>
{
if (col.GetFieldName() == nameof(Foo.Education))
{
col.ComponentType = typeof(Select<string>);
col.Items = typeof(EnumEducation).ToSelectList(new SelectedItem("", not set));
}
});
Education
column using the Select
componentThis example is used to test keyboard support in Excel
mode
Demo
Currently supported Tab
When using DatTable
as the data source, you need to follow the steps below to set
TItem
property of the Table
component to DynamicObject
DynamicContext
property of the Table
component to the DataTableDynamicContext
instanceprotected override void OnInitialized()
{
base.OnInitialized();
DataTableDynamicContext = new(UserData, (context, col) =>
{
// Set the Enum type to render to Select
if (col.GetFieldName() == nameof(Foo.Education))
{
col.ComponentType = typeof(Select<string>);
// Convert enum to List
col.Items = typeof(EnumEducation).ToSelectList(new SelectedItem("", NullItemText.Value));
}
});
}
DataRow
change logicOnChanged
callback delegate function to handle the New/Delete logicprotected override void OnInitialized()
{
DataTableDynamicContext.OnChanged = args =>
{
// output log information
Trace.Log($"# valueS: {args.Items.Count()} - type: {args.ChangedType}");
return Task.CompletedTask;
};
}
DataCell
change logicOnValueChanged
callback delegate function to handle the cell update logicprotected override void OnInitialized()
{
// Get built-in OnValueChanged callback
var method = DataTableDynamicContext.OnValueChanged;
DataTableDynamicContext.OnValueChanged = async (model, col, val) =>
{
// Invoke internally provided methods
if (method != null)
{
// The internal method updates the original data source DataTable
await method(model, col, val);
}
// output log information
Trace.Log($"Change Notification: {col.GetFieldName()} - Value: {val?.ToString()}");
};
}
B station related video link
交流群