MPage Table Component
Overview
The MPage table component offers a simple one line option for transforming your Angular data objects into fully interactive tables. The table offers many advanced features which are all controlled through various settings you assign in your MPage code. The MPage table component dynamically adjusts its height and width to the available space of its parent container and works well with the remaining screen space directive. Column names are automatically converted to human-readable text (e.g. lastName becomes Last Name) and users can resize columns to any width they desire.
Required Imports
To use the MPage table in your component, you must import the MpageTableComponent from @clinicaloffice/mpage-developer and include it in your component imports array in your component TypeScript file.
e.g. your-component.ts
import {MpageTableComponent} from '@clinicaloffice/mpage-developer'; @Component({ selector: 'your-component', imports: [MpageTableComponent], templateUrl: './your-component.component.html', styleUrl: './your-component.component.scss', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush }) export class YourComponent { }
Usage
At a minimum, the MPage table component requires a data object to render a table. For all examples in this document, we will be using an object array called tableData, however, you can also use signals and data arrays stored in any of the Clinical Office data services.
<mpage-table [data]="tableData" />
The table in the previous example has filled the entire content of the page and has scrolled off the bottom of the screen. Horizontally, an empty zone is displayed once the table data has been rendered.
The table will automatically allow sorting by clicking the column headers and can be filtered by entering values in the filter prompts below the titles. The filter prompts automatically determine the type of prompt to show based on the content and data field name.
Other text values can have search values typed in and clicking the prefix icon switches the filter search from "starts with" to "contains". This enables your users to have the ability to control how they search for text.
Columns which have object names ending with DtTm or Date will be treated as date values and offer extensive date range filtering.
If a text column on your table has a short list of unique values, a select drop-down will be used for the filter allowing multiple filter selections.
The MPage table is equipped with virtual scrolling when embedded in a parent container with a fixed size. In the next example, we nest the table component inside a div using the coRemainingScreenSpace directive. The table sizing is now completely responsive to any changes in the window size. Scrollbars appear only when needed to allow navigation in the table. The header row and filter row are locked in place and will always be visible.
<div coRemainingScreenSpace>
<mpage-table [data]="tableData" />
</div>
Options
The MPage table component offers several options for customization which are listed in the table below. Options can be applied directly in your HTML element.
<mpage-table [data]="tableData" (clickRow)="rowClicked($event) [params]="{showToolbar: true}" />
| Option | Binding | Data Type | Description |
|---|---|---|---|
| clickColumn | Output | event emitter |
Passes a column click event to the assigned method in the format of
(clickColumn)="yourClickHandlerMethod($event)".
$event contains: {
"column": "Name of column clicked",
"columnData": "Data inside of clicked column",
"row": {Object containing entire row data was clicked on}
}
|
| clickContextMenu | Output | event emitter |
Passes a context menu click event to the assigned method in the format of
(clickContextMenu)="yourClickHandlerMethod($event)".
Note: Requires the contextMenu array to be populated in the params option. $event contains: {
"contextMenuAction": "ID or Name of menu item clicked",
... all fields in row clicked ...
}
|
| clickRow | Output | event emitter |
Passes a row click event to the assigned method in the format of
(clickRow)="yourClickHandlerMethod($event)".
$event contains the entire row object. |
| columnConfig | Input/Output | IColumnConfig object | The columnConfig option contains a detailed list of columns and sorting options that control how the table columns are displayed. If not assigned, a IColumnConfig object is automatically generated in the table. It is exposed here to allow you the ability to force a specific layout of the table. |
| columnStyleLogic | Input | any |
The columnStyleLogic option gives you the ability to pass a function to your table for the purpose of
changing styles of a table column.
Your custom function must have two parameters. The first being a string parameter called column and a
data parameter with an any type. Your function must return a data type of any.
The column parameter represents the name of the column being referenced in the call where data represents the entire row of data. The returning data must be in a format usable by the style property in Angular. Care should be taken not to increase the height of a column or row as it will have a negative effect on table scrolling. In the example below, we are setting the font to bold-underline on any column where the column name is equal to 'vip' and the vip column on the row is set to true. protected myStyleLogic(column: string, data: any): any {
if (data && column === 'vip' && data.vip) {
return {
fontWeight: '600',
textDecoration: 'underline'
}
}
}
|
| data | Input | array object |
This is the array that contains the data you wish to display in the table. The table component does make assumptions concerning the data array being passed to it.
|
| filteredData | Output | event emitter |
The filteredData event emitter makes all data in your table available with the user filters applied. For example, if you pass in an array with 1,000 different last names and search for "Simpson", only the rows with the last name of "Simpson" will be available in filteredData. We commonly use this emitter to export user filtered data outside the MPage to Excel. To assign the filtered data to an array called fData you would add (filteredData)="fData = $event". |
| params | Input | ITableParams object | The params object contains the customization options for the table component. The available options are numerous and discussed in detail further into this documentation. |
Customizing the table parameters
The params input ITableParams object has been designed to allow maximum flexibility in how your table is displayed to end users. Every property in the params object is optional, meaning you only have to assign the values you want to change.
The properties are as follows:
| Property Name | Description | Data Type | Default Value |
|---|---|---|---|
| allowColumnSort | Indicates if users can click the column title to sort data. | boolean | true |
| allowWheelScroll | Indicates if users can use the mouse wheel to scroll through the table. | boolean | true |
| autoResize | Allows auto-resizing of table component. If set to false, the entire table is rendered. | boolean | true |
| columnFilter | Enables or disables the filter row | boolean | true |
| contextMenu | Assigns the right-click context menu content | IMenuItem[] | [] |
| dtTmLabel | Label to display for Date/Time fields | string | "Date/Time" |
| emptyDateLabel | Label to display if a Date/Time or Date field is empty | string | |
| enableCheckBoxes | If set to true, any check box fields on the table will allow user interaction. Interactions are reflected in the (filteredData) emitter allowing for further action in your code. | boolean | false |
| extraToolbarButtons | Allows you the ability to define additional buttons on the toolbar | IMenuItem[] | [] |
| filterThreshold | Assign the number of rows to allow before user has to hit enter key to filter content. | number | 1000 |
| hideCdValues | Hide columns ending with Cd | boolean | true |
| hideIdValues | Hide columns ending with Id | boolean | true |
| hoverValue | Determines if the content of a column should show as hover text. Useful as a quick display of data that is too long to be displayed. | boolean | true |
| listFilterSize | Number of unique values before select list becomes a text search. | number | 15 |
| maxInitialColumnWidth | Determines the maximum size in pixels that a column width will auto-size to. | number | 300 |
| noDataLabel | Label to display if no data available for table. | string | No Results Available |
| noFilteredDataLabel | Label to display if no data qualifies during user filtering. | string | No Results Qualified for Filter |
| showToolbar | Indicates if toolbar should be shown to users. Exposing the toolbar offers users the ability to change the display properties and order of columns, perform multi-column sorting and more. | boolean | false |
| textJustification | Assign the default text alignment of columns. Valid values are 'left','center','right' | string | 'left' |
Automatic Field Name Handling
Field names in your data object determine how content is displayed on the table. Some field names will hide values, where others may display date formatting, an icon, or a checkbox.
The table below demonstrates the variations. In every case, the field name described ends with the value shown in the table (e.g. eventCd = Cd, event_cd = _cd). Any value not in the table below is treated as plain text.
Field titles will be derived from the field name. For example, name_full_formatted (nameFullFormatted) will display as "Name Full Formatted". Date/Time fields will display the dtTmLabel property in the params input in place of dtTm in the field name. (e.g. (CCL) inpatient_admit_dt_tm -> (JS) inpatientAdmitDtTm -> "Inpatient Admit Date/Time").
| JavaScript Field Name | CCL Record Structure Field Name | Description |
| Cd | _cd | Code Value. Will not display on table unless hideCdValues in params set to false. |
| Chkbox | _chkbox |
Will convert an integer 0/1 value to a checkbox on screen. In your CCL script, the record structure
element for your _chkbox field needs to be an i4 type.
To allow users the ability to check/un-check the checkbox values you need to apply the enableCheckBoxes parameter. |
| Date | _date | Will format a Date/JS Date as a date without time. |
| DtTm | _dt_tm | Will format a Date/JS Date as a date/time string. |
| Icon | _icon | Will render an icon. Text in the field should be in the format of icon name paired with a color name and separated with a pipe delimiter (e.g. "person|primary"). Omitting the color portion will display the icon with the current text color (e.g. "person"). |
| Id | _id | Cerner numeric Id. Will not display on table unless hideIdValues in params set to false. |
Customizing Columns with columnConfig
Every MPage table object contains a columnConfig regardless of whether you assigned an object with the columnConfig option. If you have assigned an IColumnConfig object to your table with the columnConfig option, you have opened up the possibility to allow programmable customization.
<mpage-table [columnConfig]="myColumnConfig" />
IColumnConfig objects contain two arrays. The first is called columns and is an IColumn array where the second array is called columnSort which is an IColumnSort array. Columns displayed in your table are displayed in order from left to right based on the position in the columns array. In the example below, columns will be displayed in the order of patientName, mrn, and birthDate.
const myColumnConfig: IColumnConfig = {
columns: [
{ column: 'patientName', label: 'Patient Name', type: 'Text', visible: true, sticky: true, width: 300, justification: 'left' },
{ column: 'mrn', label: 'Medical Record Number', type: 'Text', visible: true, sticky: false, width: 150, justification: 'center' },
{ column: 'birthDate', label: 'Birth Date', type: 'Date', visible: true, sticky: false, width: 200, justification: 'center' }
],
columnSort: [
{ column: 'patientName', sortDirection: 'asc' },
{ column: 'mrn', sortDirection: 'asc' }
]
}
If you do not include every field in your data object when assigning a custom column config, those fields will automatically be added to the IColumnConfig, however, the visible property will be set to false.
Context Menus and Extra Toolbar Buttons
Adding a right-click context menu and/or extra buttons to the toolbar is simple in the MPage table component.
To add a right-click context menu, you need to populate the contextMenu entry in your params object with an array of IMenuItem items. At a minimum, you need to populate a label value.
- idName: Identifier name to pass back to the contextMenuAction property in the clickContextMenu emitter.
- icon: Material Icon to display next to the label.
- label: Label text to display in the menu. If idName is omitted, label will be passed to the contextMenuAction property. If a blank string is passed to the label, a separator bar will be displayed.
- hoverText: Text to display when user hovers mouse over context menu row.
The example context menu below demonstrates the different display options available.
contextMenu: [
{
idName: 'med-info',
icon: 'medical_information',
label: 'Open Patient Chart',
hoverText: 'Open the patient chart in PowerChart'
},
{
label: ''
},
{
icon: 'person',
label: 'Patient Information'
},
{
icon: 'biotech',
label: 'Latest labs'
},
{
icon: 'calendar_month',
label: 'Upcoming Appointments'
}
]
Extra buttons on the toolbar are also possible by assigning an IMenuItem[] array to your params.extraToolbarButtons object. The same properties are available as your context menu, however, the label property is not displayed. It will be passed to the contextMenuAction property in the clickContextMenu emitter if idName has not been assigned.
The extra buttons added to your toolbar only pass a value of contextMenuAction to the clickContextMenu emitter where a context menu additional sends the fields available on the row that was clicked when triggering the context menu.
extraToolbarButtons: [
{
idName: 'excel',
icon: 'save_as',
hoverText: 'Export to Excel'
},
{
icon: 'help',
label: 'Help',
hoverText: 'Open help'
}
]
Styling
The table below describes the styles specific to the MPage Table component that you can customize. These changes are global to your MPage. If you are building a component to be used in the Cerner MPage Component Framework, these styles are specific to your component and changes will have no impact on other Clinical Office components displayed on the same page.
| SCSS Variable Name | Default Value | Description |
|---|---|---|
| --mpage-table-container-border | Perimeter border around the entire table. | |
| --mpage-table-font-size | inherit | Font size of table content |
| --mpage-table-header-height | 40px | Height of the title header row on the table. |
| --mpage-table-header-background-color | Table header row background color. | |
| --mpage-table-row-height | 36px | Height of each row of table data |
| --mpage-table-background-color | Background color of table content. | |
| --mpage-table-cell-border | Table cell border color. | |
| --mpage-table-sort-arrow-color | Color of up/down arrow in table header to indicate sorting. | |
| --mpage-table-filter-background-color | Background color of table filter rows. | |
| --mpage-table-toolbar-box-height | fit-content | Change to 'unset' to have toolbar extend to the entire height of the table. |
| --mpage-table-toolbar-background-color | Toolbar background color | |
| --mpage-table-toolbar-border-radius | 0 | Set the roundness of the toolbar border. |
| --mpage-table-toolbar-box-shadow | Shadow around toolbar | |
| --mpage-table-toolbar-icon-color | Toolbar icon color | |
| --mpage-table-toolbar-padding | 8px | Toolbar content padding |
| --mpage-table-toolbar-drag-background | Background color of draggable content inside the toolbar (e.g. Repositioning columns). | |
| --mpage-table-toolbar-drag-padding | 8px | Padding around draggable content inside the toolbar. |
| --mpage-table-toolbar-drag-border | unset | Border around draggable content inside the toolbar. |
| --mpage-table-toolbar-drag-border-alternate | 2px solid | Border around draggable content inside the toolbar while user is hovering the mouse over the content. |
| --mpage-table-toolbar-drag-border-radius | 0 | Border radius (roundness) of draggable content inside the toolbar. |
| --mpage-table-empty-space-background | Background to display in areas where there may be dead-space on the table. |
Interfaces
ITableParams {
allowWheelScroll?: boolean;
showToolbar?: boolean;
allowColumnSort?: boolean;
hideIdValues?: boolean;
hideCdValues?: boolean;
dtTmLabel?: string;
emptyDateLabel?: string;
contextMenu?: IMenuItem[];
extraToolbarButtons?: IMenuItem[];
textJustification?: string;
columnFilter?: boolean;
filterThreshold?: number;
listFilterSize?: number;
autoResize?: boolean;
maxInitialColumnWidth?: number;
hoverValue?: boolean;
}
IFilter {
type: string;
column: string;
values: any[];
search: any[];
}
IColumn {
column: string;
label: string;
type: string;
visible: boolean;
sticky: boolean;
width: number;
justification: string;
calculation?: string;
}
IColumnSort {
column: string;
sortDirection: string;
}
IColumnConfig {
columns: IColumn[];
columnSort: IColumnSort[];
}
IMenuItem {
idName?: string;
icon?: string;
label?: string;
hoverText?: string;
}