Class GridEditScreenBase<TModel, TListModel>
- Namespace
- Dynamicweb.CoreUI.Screens
- Assembly
- Dynamicweb.CoreUI.dll
Base class for CoreUI grid-edit screens that render an inline-editable data grid. Subclass this to create a screen where users can edit multiple records directly in a grid.
public abstract class GridEditScreenBase<TModel, TListModel> : ScreenBase where TListModel : DataListViewModel<TModel>
Type Parameters
TModelThe row model type. Must derive from DataViewModelBase.
TListModelThe list-wrapping model type. Must derive from DataListViewModel<T>.
- Inheritance
-
GridEditScreenBase<TModel, TListModel>
- Derived
- Inherited Members
Remarks
Override GetColumns() to define the editable columns, GetSaveCommand() to supply the command that persists changes, and GetScreenName() to set the screen title. Use CreateColumn<TValue>(Expression<Func<TModel, TValue>>, GridColumnComponentDefinition?, bool, bool, bool, bool?) to build strongly-typed column definitions.
Properties
Query
Gets the data query used to populate the grid. Set by the framework before the screen is built.
public DataQuerySimpleListBase<TModel, TListModel>? Query { get; }
Property Value
- DataQuerySimpleListBase<TModel, TListModel>
Methods
CreateColumn(string, GridColumnComponentDefinition?, bool, bool, bool, bool?)
Creates a GridColumn from a model property identified by its system name. Call this from GetColumns() when you cannot use a compile-time expression.
protected GridColumn? CreateColumn(string systemName, GridColumnComponentDefinition? columnTemplate = null, bool enableFind = true, bool enableSetValueAction = true, bool enableSearchAndReplaceAction = true, bool? isGroupable = null)
Parameters
systemNamestringThe system name of the model property to build the column for.
columnTemplateGridColumnComponentDefinitionAn optional cell component definition overriding the auto-resolved editor type.
enableFindboolWhether the find action is enabled for this column. Defaults to
true.enableSetValueActionboolWhether the set-value bulk action is enabled. Defaults to
true.enableSearchAndReplaceActionboolWhether the search-and-replace action is enabled. Defaults to
true.isGroupablebool?Whether the column can be used for row grouping. Defaults to
truewhennull.
Returns
- GridColumn
A configured GridColumn, or
nullif no mapping exists forsystemName.
CreateColumn<TValue>(Expression<Func<TModel, TValue>>, GridColumnComponentDefinition?, bool, bool, bool, bool?)
Creates a GridColumn from a strongly-typed model property expression. Call this from GetColumns() to build column definitions.
protected GridColumn CreateColumn<TValue>(Expression<Func<TModel, TValue>> expression, GridColumnComponentDefinition? columnTemplate = null, bool enableFind = true, bool enableSetValueAction = true, bool enableSearchAndReplaceAction = true, bool? isGroupable = null)
Parameters
expressionExpression<Func<TModel, TValue>>A lambda expression pointing to the model property, e.g.
m => m.Name.columnTemplateGridColumnComponentDefinitionAn optional cell component definition overriding the auto-resolved editor type.
enableFindboolWhether the find action is enabled for this column. Defaults to
true.enableSetValueActionboolWhether the set-value bulk action is enabled. Defaults to
true.enableSearchAndReplaceActionboolWhether the search-and-replace action is enabled. Defaults to
true.isGroupablebool?Whether the column can be used for row grouping. Defaults to
truewhennull.
Returns
- GridColumn
A configured GridColumn ready to be returned from GetColumns().
Type Parameters
TValueThe property value type.
CreateSorting<TValue>(Expression<Func<TModel, TValue>>, SortDirection)
Creates a SortInfo entry for a model property, for use in GetSorting().
protected SortInfo CreateSorting<TValue>(Expression<Func<TModel, TValue>> columnExpression, SortDirection direction)
Parameters
columnExpressionExpression<Func<TModel, TValue>>A lambda expression pointing to the model property to sort by.
directionSortDirectionThe sort direction (Ascending or Descending).
Returns
- SortInfo
A SortInfo that can be returned from GetSorting().
Type Parameters
TValueThe property value type.
GetColumnRules(string)
Returns conditional styling or behavior rules for the column with the given system name. Called once per column when building the grid.
protected virtual IEnumerable<GridColumnRule?>? GetColumnRules(string systemName)
Parameters
systemNamestringThe system name of the column.
Returns
- IEnumerable<GridColumnRule>
A collection of GridColumnRule instances, or
nullfor no rules.
GetColumns()
Returns the configurable columns that users can show, hide, and reorder. This is the primary override point for defining the grid's editable fields. Called once when building the grid.
protected virtual IEnumerable<GridColumn>? GetColumns()
Returns
- IEnumerable<GridColumn>
A collection of GridColumn instances, or
nullfor no columns.
GetCustomConfiguration()
Returns a custom screen configuration that overrides field inclusion or freeze settings for this screen.
Called when resolving the active configuration. Return null to use the default configuration.
protected virtual GridEditScreenConfiguration? GetCustomConfiguration()
Returns
- GridEditScreenConfiguration
A GridEditScreenConfiguration override, or
null.
GetDefaultGridConfiguration()
Returns the default grid configuration used when no user preset or custom configuration is active. Override to control which fields are included or excluded by default.
protected virtual GridEditScreenConfiguration GetDefaultGridConfiguration()
Returns
- GridEditScreenConfiguration
A GridEditScreenConfiguration representing the screen's default field set.
GetDefinitionInternal()
Builds and returns the raw component tree for this screen.
protected override sealed UiComponentBase GetDefinitionInternal()
Returns
Remarks
Implement this method in every concrete screen class. The result is post-processed by GetDefinition() (injectors, trimming, preset actions) before being returned to the framework.
GetDynamicFieldColumnDefinition(string)
Returns a custom cell component definition for a dynamic field column identified by its system name. Called when a dynamic field column has no value-type-based default definition.
protected virtual GridColumnComponentDefinition? GetDynamicFieldColumnDefinition(string systemName)
Parameters
systemNamestringThe system name of the dynamic field.
Returns
- GridColumnComponentDefinition
A GridColumnComponentDefinition for the cell editor, or
nullto use the auto-resolved default.
GetGroupingColumn()
Returns the name of the column by which rows are visually grouped in the grid. Called once when building the grid component.
protected virtual string? GetGroupingColumn()
Returns
- string
The column name to group by, or
nullto disable grouping.
GetSaveCommand()
Returns the command that persists all grid edits when the user saves. Called once when building the save button.
protected virtual CommandBase? GetSaveCommand()
Returns
- CommandBase
A CommandBase that saves grid changes, or
nullto render the screen without a save button.
GetScreenName()
Returns the display name shown in the screen's title bar and grid header. Called once when building the screen layout.
protected virtual string GetScreenName()
Returns
- string
A human-readable screen name. Defaults to
"Grid Edit".
GetSorting()
Returns the initial sort order applied to the grid when it is first rendered. Called once when building the grid component.
protected virtual IEnumerable<SortInfo>? GetSorting()
Returns
- IEnumerable<SortInfo>
A collection of SortInfo entries defining column and direction, or
nullfor no default sort.
GetStaticColumns()
Returns columns that are always present regardless of the user's field configuration, and whose order is not affected by the user's column ordering preferences. Called once when building the grid.
protected virtual IEnumerable<GridColumn>? GetStaticColumns()
Returns
- IEnumerable<GridColumn>
A collection of always-shown GridColumn instances, or
null.
ModifyDynamicFieldColumn(ModelDynamicFieldInfo, GridColumn)
Allows modifying a GridColumn after it has been auto-generated for a dynamic field. Called once per dynamic field column when building the grid.
protected virtual void ModifyDynamicFieldColumn(ModelDynamicFieldInfo dynamicField, GridColumn column)
Parameters
dynamicFieldModelDynamicFieldInfoMetadata about the dynamic field.
columnGridColumnThe auto-generated column to modify in place.
OnBuildGridEditScreen()
Called once before the grid layout is built, allowing subclasses to perform setup work
such as loading auxiliary data or setting configuration flags.
Override this instead of overriding the sealed GetDefinitionInternal.
protected virtual void OnBuildGridEditScreen()