83 lines
3.5 KiB
Markdown
83 lines
3.5 KiB
Markdown
# MgGrid — Parameters & Events
|
|
|
|
> Part of the MgGrid system. See `README.md` for overview and component hierarchy.
|
|
|
|
## Required Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
|---|---|---|
|
|
| `SignalRClient` | `AcSignalRClientBase` | SignalR client for server communication |
|
|
| `Logger` | `TLoggerClient` | Logger instance |
|
|
| `GetAllMessageTag` | `int` | SignalR tag for loading all items |
|
|
|
|
## CRUD Message Tags
|
|
|
|
| Parameter | Type | Description |
|
|
|---|---|---|
|
|
| `GetAllMessageTag` | `int` | Tag for "get all items" request |
|
|
| `GetItemMessageTag` | `int` | Tag for "get single item" request |
|
|
| `AddMessageTag` | `int` | Tag for "add item" request |
|
|
| `UpdateMessageTag` | `int` | Tag for "update item" request |
|
|
| `RemoveMessageTag` | `int` | Tag for "remove item" request |
|
|
|
|
These are bundled into a `SignalRCrudTags` during `OnInitializedAsync`. See `AyCode.Services.Server/docs/SIGNALR_DATASOURCE/README.md` (in AyCode.Core repo) for details.
|
|
|
|
## Data & Context Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
|---|---|---|
|
|
| `DataSource` | `IList<TDataItem>` | Bind with `AcObservableCollection<TDataItem>` for external data. If not set, grid creates its own. |
|
|
| `ParentDataItem` | `IId<TId>?` | Parent entity for detail grids. `null` = master grid. |
|
|
| `KeyFieldNameToParentId` | `string?` | Property name on `TDataItem` that references the parent's ID |
|
|
| `ContextIds` | `object[]?` | Additional context passed to `AcSignalRDataSource` constructor |
|
|
| `FilterText` | `string?` | Text filter — propagated to data source, triggers reload |
|
|
|
|
## Display & Behavior Parameters
|
|
|
|
| Parameter | Type | Default | Description |
|
|
|---|---|---|---|
|
|
| `Caption` | `string` | `typeof(TDataItem).Name` | Grid title (shown in fullscreen header) |
|
|
| `GridName` | `string` | `"{TDataItem.Name}Grid"` | Name used in log messages |
|
|
| `AutoSaveLayoutName` | `string?` | `"Grid{TDataItem.Name}"` | Base name for layout storage keys |
|
|
|
|
## Event Callbacks
|
|
|
|
All grid events are re-exposed with `OnGrid` prefix to avoid collisions with `DxGrid` base events:
|
|
|
|
| Event | DxGrid Equivalent | When Fired |
|
|
|---|---|---|
|
|
| `OnGridItemDeleting` | `DataItemDeleting` | Before item removal (can cancel via `e.Cancel`) |
|
|
| `OnGridEditModelSaving` | `EditModelSaving` | Before item save (can cancel via `e.Cancel`) |
|
|
| `OnGridEditStart` | `EditStart` | When edit mode begins |
|
|
| `OnGridCustomizeEditModel` | `CustomizeEditModel` | When edit model is being prepared |
|
|
| `OnGridFocusedRowChanged` | `FocusedRowChanged` | When focused row changes |
|
|
| `OnDataSourceChanged` | — | After data source is loaded/reloaded |
|
|
| `OnGridItemChanged` | — | After server confirms a CRUD operation |
|
|
| `OnGridItemChanging` | — | Before a CRUD operation is sent to server |
|
|
|
|
Internal event wiring (in `SetParametersAsyncCore`, first call):
|
|
|
|
| DxGrid Event | → Internal Handler |
|
|
|---|---|
|
|
| `DataItemDeleting` | `OnItemDeleting` |
|
|
| `EditModelSaving` | `OnItemSaving` |
|
|
| `CustomizeEditModel` | `OnCustomizeEditModel` |
|
|
| `FocusedRowChanged` | `OnFocusedRowChanged` |
|
|
| `EditStart` | `OnEditStart` |
|
|
| `EditCanceling` | `OnEditCanceling` |
|
|
|
|
## Default Grid Settings
|
|
|
|
Set in `SetParametersAsyncCore` (first call only):
|
|
|
|
| Setting | Value |
|
|
|---|---|
|
|
| `KeyFieldName` | `"Id"` |
|
|
| `TextWrapEnabled` | `false` |
|
|
| `AllowSelectRowByClick` | `true` |
|
|
| `HighlightRowOnHover` | `true` |
|
|
| `AutoCollapseDetailRow` | `true` |
|
|
| `AutoExpandAllGroupRows` | `false` |
|
|
|
|
Project adapters typically add more defaults in `OnParametersSet` (e.g., `EditMode`, `FocusedRowEnabled`, `PageSize`, `ShowFilterRow`, `SizeMode` based on `IsMasterGrid`).
|