File

src/ui/viewer/smart-viewer.component.ts

Extends

AbstractFrameComponent

Implements

OnInit AfterViewInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor(dsRegistry: DataSourceRegistry, toolbarRegistry: SmartToolbarRegistry, navigationService: SmartNavigationService, vcRef: ViewContainerRef, changeDetector: ChangeDetectorRef, viewerRegistry: SmartViewerRegistryService, ssehService: SmartViewerServerSideEventHandlerService, smartTabFolderHelperService: TabParentService, smartFormInstanceService: SmartFormInstanceService, injector: Injector)
Parameters :
Name Type Optional
dsRegistry DataSourceRegistry No
toolbarRegistry SmartToolbarRegistry No
navigationService SmartNavigationService No
vcRef ViewContainerRef No
changeDetector ChangeDetectorRef No
viewerRegistry SmartViewerRegistryService No
ssehService SmartViewerServerSideEventHandlerService No
smartTabFolderHelperService TabParentService No
smartFormInstanceService SmartFormInstanceService No
injector Injector No

Inputs

focusOnAdd
Type : string

If set, the Smart Viewer will focus this field when it's attached data source adds a record.

focusOnCopy
Type : string

If set, the Smart Viewer will focus this field when a record is copied.

focusOnUpdate
Type : string

If set, the Smart Viewer will focus this field when it's attached data source updates a record.

smart-data-source
Type : string

The name of the SmartDataSource that the Smart Viewer should attach itself to.

smart-event-handlers
Type : SSEHEventHandlerDefinitions
smart-group-assign-source
Type : string

If set, the Smart Viewer will behave as if it were a TableIO target of the group assign source's TableIO source

smart-save-mode
Type : boolean
smart-show-date-time-zone
Type : boolean | undefined

Sets whether DATETIME-TZ timezone badges/selectors are displayed.

smart-table-ref
Type : string
smart-tableio-source
Type : string

If set, the Smart Viewer will attempt to find the SmartToolbarComponent registered under this name and listen to button clicked events.

smart-viewer-layout
Type : any

The layout (template) that the Smart Viewer should fetch and render.

smart-viewer-settings
Type : literal type
smart-help-url
Type : string

The help URL

smart-layout-type
Type : SmartFrameLayoutType
smart-logic-classes
Type : string[]
smart-object-name
Type : string
prompt-before-delete
Type : string
ignoreFlexboxLayout
Type : boolean
smart-help-text
Type : string | undefined

Sets the HelpText value for this form child.

smart-instance-name
Type : string

The instance name of the component

Outputs

onAdd
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when an add operation is performed

onBeforeAdd
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when a before add operation is performed

onBeforeDelete
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when a before delete operation is performed

onBeforeUpdate
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when a before update operation is performed

onDelete
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when a delete operation is performed

onUpdate
Type : EventEmitter<ISmartCUDEventsArgs>

Emitted when an update operation is performed

selectedChange
Type : EventEmitter<any>
viewerButtonClicked
Type : EventEmitter<SmartViewerFieldSettings>
buttonClicked
Type : EventEmitter<SmartViewerFieldSettings>
inputBlurred
Type : EventEmitter<string>
inputFocused
Type : EventEmitter<string>
inputValueChanged
Type : EventEmitter<InputChangedEventArgs>

Fires when an input belonging to the Smart Viewer changes it's value.

onAfterAddRecord
Type : EventEmitter<AfterAddEventArgument>
onAfterCancelRecord
Type : EventEmitter<AfterCancelEventArgument>
onAfterCopyRecord
Type : EventEmitter<AfterCopyEventArgument>
onAfterDeleteRecord
Type : EventEmitter<AfterDeleteEventArgument>
onAfterEnableFields
Type : EventEmitter<AfterEnableFieldsEventArgument>
onAfterSaveChanges
Type : EventEmitter<AfterSaveChangesEventArgument>
onBeforeAddRecord
Type : EventEmitter<BeforeAddEventArgument>
onBeforeCancelRecord
Type : EventEmitter<BeforeCancelEventArgument>
onBeforeCopyRecord
Type : EventEmitter<BeforeCopyEventArgument>
onBeforeDeleteRecord
Type : EventEmitter<BeforeDeleteEventArgument>
onBeforeEnableFields
Type : EventEmitter<BeforeEnableFieldsEventArgument>
onBeforeSaveChanges
Type : EventEmitter<BeforeSaveChangesEventArgument>

Methods

Public callLogicClassMethod
callLogicClassMethod(methodName: string, args: any[])

Invokes a specified method on the first available logic class instance that has the method defined.

Parameters :
Name Type Optional Description
methodName string No
  • The name of the method to call.
args any[] No
  • An array of arguments to pass to the method.
Returns : void
checkViewerForUnboundFields
checkViewerForUnboundFields(viewerLayout: any)
Parameters :
Name Type Optional
viewerLayout any No
Returns : void
componentLoaded
componentLoaded()

Used internally. Sets up key listeners on child input elements that trigger the UPDATING state on the attached datasource when values are changed.

Returns : void
disableViewer
disableViewer()

Disables all inputs within the Smart Viewer.

Returns : void
Public Async enableFieldsForUpdate
enableFieldsForUpdate()

Enables the fields in the viewer - update button in saveMode = false

Returns : any
Public enableGroupAssignToolbarMode
enableGroupAssignToolbarMode(toolbar: SmartToolbarComponent)

Switches this viewer into subscription-based toolbar event dispatch because it is the root of a group-assign chain.

Parameters :
Name Type Optional Description
toolbar SmartToolbarComponent No
  • The shared TableIO toolbar.
Returns : void
Async enableViewer
enableViewer(context?: TableIOTargetContext)

Enables all inputs within the Smart Viewer.

Parameters :
Name Type Optional
context TableIOTargetContext Yes
Returns : Promise<boolean>
Public getDataSource
getDataSource(dataSourceName?: string)

Returns the datasource as an observable

Parameters :
Name Type Optional Description
dataSourceName string Yes
  • The name of the datasource to return. If not provided, the viewer's datasource is returned.

the datasource

Public getFieldReference
getFieldReference(fieldName: string)
Type parameters :
  • T

Returns field reference

Parameters :
Name Type Optional Description
fieldName string No

the field name

Returns : T
getSelectedRecords
getSelectedRecords()

Returns the selected records

Returns : any[]

the selected records

getTableIoSource
getTableIoSource()

Returns the toolbar that is used as the table IO source

the toolbar that is used as the table IO source

Public getToolbarDispatchPolicy
getToolbarDispatchPolicy(button: SmartToolbarButtonComponent)

Returns the click-time toolbar dispatch policy for this viewer.

Parameters :
Name Type Optional Description
button SmartToolbarButtonComponent No

The clicked toolbar button.

The click-time dispatch policy.

Public getWidgetFacade
getWidgetFacade(fieldName: string)

Returns a widget facade

Parameters :
Name Type Optional Description
fieldName string No

the field name

Returns : IWidgetFacade
Public handleAdd
handleAdd()

Handles an add operation

Returns : void
Public handleCancel
handleCancel(downstramToDataSource: unknown)

Handles a cancel operation

Parameters :
Name Type Optional Default value
downstramToDataSource unknown No true
Returns : void
Public handleCopy
handleCopy()

Creates a clone of the current record and uses it to perform an add operation on the attached datasource.

Returns : void
Public Async handleDelete
handleDelete()

Handles a delete operation

Returns : any
Public handleSave
handleSave()

Handles a save operation

Returns : void
Public handleSuppressedToolbarButton
handleSuppressedToolbarButton(button: SmartToolbarButtonComponent, context: TableIOToolbarDispatchContext)

Restores viewer presentation state after a consumer suppresses central Cancel dispatch without starting a datasource record transaction.

Parameters :
Name Type Optional Description
button SmartToolbarButtonComponent No

The clicked toolbar button.

context TableIOToolbarDispatchContext No

The accepted click state.

Returns : void
Public handleToolbarButton
handleToolbarButton(button: SmartToolbarButtonComponent, context?: TableIOToolbarDispatchContext)

Handles a toolbar button click routed through the active TableIO target.

Parameters :
Name Type Optional Description
button SmartToolbarButtonComponent No

The clicked toolbar button.

context TableIOToolbarDispatchContext Yes

The accepted click state.

Returns : boolean

True when the viewer handled the button.

Public handleToolbarCancel
handleToolbarCancel()

Handles toolbar cancel using group-assign ownership semantics.

Returns : void
Public handleUpdate
handleUpdate()

Enables the fields for update

Returns : void
Public handleView
handleView()

Handles a view operation

Returns : void
Public Async saveChanges
saveChanges()

Saves the viewer's current datasource changes and resolves after the save-side TableIO state cleanup has completed.

Returns : Promise<void>
Public Async setFieldEnabled
setFieldEnabled(field: any, enabled: boolean)

Given a field definition, sets it's enabled state If a fieldset or field group is provided, it's child fields' enabled state will be updated

Parameters :
Name Type Optional
field any No
enabled boolean No
Returns : any

Promise

Public syncToolbarWithTableIOState
syncToolbarWithTableIOState(toolbar: ISmartTableIOSource)

Syncs the toolbar button states with the current state of this table IO target. This method is called when the target is activated and should ensure the toolbar buttons reflect the current state

Parameters :
Name Type Optional Description
toolbar ISmartTableIOSource No
  • The toolbar to sync
Returns : void
Public callLogicMethod
callLogicMethod(methodName: string, ...args: any[])

Calls a method on the logic class instances

Parameters :
Name Type Optional Description
methodName string No
  • The method name to call
args any[] No
  • Arguments to pass to the method
Returns : Promise | any

The result of the method call

checkViewersPadding
checkViewersPadding()

Updates the viewer's padding

Returns : void
focusField
focusField(fieldToFocus: string)

Moves focus to the specified viewer field input

Parameters :
Name Type Optional Description
fieldToFocus string No

The fully qualified name of the viewer field

Returns : void
handleLayoutChange
handleLayoutChange(newLayout: any)
Parameters :
Name Type Optional
newLayout any No
Returns : void
Public hasDateTimeTZSelectorPreferenceContextMenuItem
hasDateTimeTZSelectorPreferenceContextMenuItem()

Indicates whether DATETIME-TZ usage preference applies to this viewer.

Returns : boolean
Public onViewerContextMenu
onViewerContextMenu(event: MouseEvent)

Shows the viewer preference context menu when applicable.

Parameters :
Name Type Optional Description
event MouseEvent No

The context menu event.

Returns : void
Public onViewerPreferenceContextMenuItemSelected
onViewerPreferenceContextMenuItemSelected(event: ContextMenuSelectEvent)

Handles viewer preference context menu item selection.

Parameters :
Name Type Optional Description
event ContextMenuSelectEvent No

The context menu selection event.

Returns : void
trackBy
trackBy(index: number)

Tells the UI to track components by index

Parameters :
Name Type Optional
index number No
Returns : number
Async registerTableIOTarget
registerTableIOTarget()

Registers the table IO target with the registry

Returns : any
Public notifyLoadingFinished
notifyLoadingFinished(objectName: string)

Notifies the parent Smart Form that this form child has finished loading

Parameters :
Name Type Optional
objectName string No
Returns : void

void

Properties

enabledStateMonitored
Type : QueryList<EnabledStateDirective>
Decorators :
@ContentChildren(EnabledStateDirective)
self
Type : any
Default value : this
smartDs
Type : AbstractSmartDataSource
Default value : {} as SmartDataSource

The SmartDataSource instance that this viewer is attached to.

viewerLayout
Type : any
viewerTemplate
Type : SmartViewerTemplateDirective
Decorators :
@ContentChild(SmartViewerTemplateDirective)
domElement
Type : ElementRef
Decorators :
@ViewChild('fakeComponent')
fieldHeightsAdded
Type : boolean
fieldsetHeightsAdded
Type : boolean
helperService
Type : SmartViewerHelperService<AbstractFrameComponent>
isLabelsLeft
Type : boolean
maxDepthValue
Type : number
Default value : 0
smartLookups
Type : QueryList<SmartLookupComponent>
Decorators :
@ContentChildren(SmartLookupComponent)
Public viewerFormFieldsContainer
Type : ViewContainerRef
Decorators :
@ViewChild('formFieldsContainer', {read: ViewContainerRef})
viewerFormPadding
Type : number
Default value : 0
Public viewerPreferencesMenu
Type : ContextMenuComponent
Decorators :
@ViewChild('viewerPreferencesMenu', {read: ContextMenuComponent})
Public viewerPreferencesService
Type : SmartViewerPreferencesService
Public tableIoStateSignal
Type : WritableSignal<TableIOTargetState>
Default value : signal( TableIOTargetState.IDLE )

Signal that tracks the current TableIO operation state. Used for synchronizing state between group assign source/target viewers.

Public injector
Type : Injector

Accessors

readOnly
getreadOnly()

Returns whether the viewer is read-only.

Returns : boolean
setreadOnly(value: boolean)

Sets whether the viewer is read-only.

Parameters :
Name Type Optional Description
value boolean No
  • The read-only state.
Returns : void
useCentralTableIODispatch
getuseCentralTableIODispatch()

Returns whether toolbar TableIO button clicks should be centrally routed.

Returns : boolean
createDisabled
getcreateDisabled()

Returns whether record creation is disabled.

Returns : boolean
setcreateDisabled(value: boolean)

Sets whether record creation is disabled.

Parameters :
Name Type Optional Description
value boolean No
  • The create disabled state.
Returns : void
deleteDisabled
getdeleteDisabled()

Returns whether record deletion is disabled.

Returns : boolean
setdeleteDisabled(value: boolean)

Sets whether record deletion is disabled.

Parameters :
Name Type Optional Description
value boolean No
  • The delete disabled state.
Returns : void
updateDisabled
getupdateDisabled()

Returns whether record updating is disabled.

Returns : boolean
setupdateDisabled(value: boolean)

Sets whether record updating is disabled.

Parameters :
Name Type Optional Description
value boolean No
  • The update disabled state.
Returns : void
settings
getsettings()
setsettings(value: literal type)
Parameters :
Name Type Optional
value literal type No
Returns : void
showDateTimeZone
setshowDateTimeZone(value: boolean | undefined)

Sets whether DATETIME-TZ timezone badges/selectors are displayed.

Parameters :
Name Type Optional Description
value boolean | undefined No
  • The component-level display override.
Returns : void
state
getstate()

The current state of the Smart Viewer.

Returns : VIEWER_STATE
setstate(value: VIEWER_STATE)

Sets the current state of the Smart Viewer.

Parameters :
Name Type Optional Description
value VIEWER_STATE No
  • The viewer state.
Returns : void
smartViewerTemplate
setsmartViewerTemplate(value: any)

The layout (template) that the Smart Viewer should fetch and render.

Parameters :
Name Type Optional
value any No
Returns : void
viewerState
getviewerState()
Returns : StateEvents
tableIOTargetKey
gettableIOTargetKey()

The canonical key identifying this viewer as a TableIO target.

Returns : string
isActiveIOTarget
getisActiveIOTarget()

True if this Smart Viewer is the active IO target.

Returns : boolean
selected
getselected()

The viewer's attached datasource's selected record.

Returns : any
setselected(value: any)

Sets the viewer's attached datasource's selected record.

Parameters :
Name Type Optional Description
value any No
  • The selected record.
Returns : void
<!--
**************************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -                  *
* www.consultingwerk.com and other contributors as listed                *
* below. All Rights Reserved.                                            *
*                                                                        *
*  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY        *
*   KIND, either express or implied.                                     *
*                                                                        *
*  Contributors:                                                         *
*                                                                        *
**************************************************************************

--------------------------------------------------------------------------
    File        : smart-viewer.component.html
    Purpose     : Template for Smart Viewer.
    Author(s)   : Radu Nicoara
    Created     : Dec 07, 2017
--------------------------------------------------------------------------
-->
<div 
    #container id="form-container"
    (contextmenu)="onViewerContextMenu($event)">
        <form #viewerForm>
            <div #formFieldsContainer></div>
        </form>
        @if (_readDisabledSignal()) {
        <div class="row">
            <p class="col-12">* Read access is restricted.</p>
        </div>
        }
        @if (hasDateTimeTZSelectorPreferenceContextMenuItem()) {
            <kendo-contextmenu
                #viewerPreferencesMenu
                size="small"
                [collision]="{ horizontal: 'fit', vertical: 'flip' }"
                [popupAnimate]="{ type: 'fade', duration: 100, direction: 'down' }"
                (select)="onViewerPreferenceContextMenuItemSelected($event)">
                <kendo-menu-item text="Use timezones" [icon]="viewerPreferencesService.useDateTimeZones() ? 'checkbox-checked' : 'checkbox'" [data]="'use-date-time-zones'" [disabled]="!viewerPreferencesService.preferencesReady()">
                </kendo-menu-item>
            </kendo-contextmenu>
        }
</div>

./smart-viewer.component.scss

/**********************************************************************
 * Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -              *
 * www.consultingwerk.com and other contributors as listed            *
 * below. All Rights Reserved.                                        *
 *                                                                    *
 *  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY    *
 *   KIND, either express or implied.                                 *
 *                                                                    *
 *  Contributors:                                                     *
 *                                                                    *
 **********************************************************************/
/*------------------------------------------------------------------------
    File        : smart-viewer.component.scss
    Purpose     : Styles for Smart Viewer.
    Author(s)   : Radu Nicoara
    Created     : Dec 07, 2017
  ----------------------------------------------------------------------*/

::ng-deep kendo-numerictextbox .k-numeric-wrap input.k-input {
    text-align: right !important;
    height: 100% !important
}

 ::ng-deep input[disabled],
textarea[disabled],
select[disabled],
[smart-widget-disabled] {
    opacity: 1 !important;
}

::ng-deep input, ::ng-deep label {
    font-weight: normal !important;
}

::ng-deep form.k-form,
::ng-deep form.k-form-inline {
    position: relative !important;
    min-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

::ng-deep form.k-form smart-viewer-field:not(.vertical-stretch),
::ng-deep form.k-form smart-viewer-fieldset,
::ng-deep form.k-form smart-viewer-group,
::ng-deep form.k-form-inline smart-viewer-field:not(.vertical-stretch),
::ng-deep form.k-form-inline smart-viewer-fieldset,
::ng-deep form.k-form-inline smart-viewer-group  {
    flex: 0 !important;
}
::ng-deep form.k-form smart-viewer-field.vertical-stretch:not(.labels-left-field) {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

::ng-deep 
form.k-form-inline smart-viewer-field.vertical-stretch,
form.k-form smart-viewer-field.vertical-stretch.labels-left-field {
    flex: 1 !important;
    display: flex !important;
    flex-direction: row !important;
}

::ng-deep form.k-form smart-viewer-field.vertical-stretch > div,
::ng-deep form.k-form smart-viewer-field.vertical-stretch smarteditorwrapper {
    flex: 1 !important;
    display: flex !important;
}

::ng-deep form.k-form smart-viewer-field.vertical-stretch:not(.labels-left-field) > div {
    flex-direction: column !important;
}

#form-container {
    overflow-y: auto !important;
    height: 100% !important;
}

::ng-deep .absolute-layout .k-form-field.smart-checkbox label,
::ng-deep .absolute-layout .k-form-field span {
    white-space: nowrap !important;
}

::ng-deep .absolute-layout .smart-viewer-fieldset {
    margin-top: 0px !important;
}

::ng-deep .before-delete-prompt-dialog {
    z-index: 100000 !important;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""