Hello All,
I have set up a custom template for a named table in SSA. This has a column (REGISTD) of character datatype which stores a date as "yyyyddmm" . I would like to be able to reformat the output in the custom template that I have set up to show the date as "dd-mm-yyyy".
I was planning to reformat using regular expressions
var s ={data.feature.REGISTD.value}
s = s.replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')
I am not sure where to add the script in the html or ts file to get this to work. Would anyone be able advise please?
Best Regards
Andrew
Custom template files are below.
(Note, some amendments were previously made to the custom templates to enable the use of collapsible buttons).
ts fileimport { Component, NgModule, Input} from '@angular/core'
import { CommonModule } from '@angular/common';
import { PbTdCustomTemplateModule } from '../templatecomponents/pb-td-custom-template.module.ts';
import { AccordionModule } from 'ngx-bootstrap';
import { CollapseModule } from 'ngx-bootstrap';
@Component({
selector: "pb-info-LCRegistrationsCustTemp",
templateUrl: '../controller/theme/infotemplates/LCRegistrationsCustTemp.html',
styleUrls: []
})
export class LCRegistrationsCustTempComponent{
@Input() data;
readonly column_S86CbConfig = {
"name": "EXTRALARGEPLAN",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_S86Cb",
"showAs": "Text",
"label": "Extra Large Plan"
};
readonly column_gjzMQConfig = {
"name": "REGISTD",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_gjzMQ",
"showAs": "Text",
"label": "Date Registered"
};
readonly column_TuVx7Config = {
"name": "DOCUMENT",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_TuVx7",
"showAs": "Text",
"label": "Document"
};
readonly column_qEQ3eConfig = {
"name": "DIGITISED",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_qEQ3e",
"showAs": "Text",
"label": "Digitised"
};
readonly column_jRGtmConfig = {
"name": "REGISTER_ENTRY",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_jRGtm",
"showAs": "Text",
"label": "Register Entry"
};
readonly column_DOtQSConfig = {
"name": "ID",
"type": "String",
"selected": true,
"elementType": "Column",
"showLabel": true,
"showIcon": false,
"icon": "pbi-mail",
"labelPosition": "inline",
"id": "column_DOtQS",
"imageDisplayType": "flexible",
"isHideNull": false,
"showAs": "Text"
};
constructor() {}
}
@NgModule({
imports: [CommonModule,AccordionModule, PbTdCustomTemplateModule,CollapseModule],
declarations: [LCRegistrationsCustTempComponent ],
exports: [LCRegistrationsCustTempComponent]
})
export class LCRegistrationsCustTempModule{ };
html file<div style="width: 100%; overflow:auto;">
<div style="float:left; width:100%; text-align:center; padding-left:4%; padding-right:2%">
<button type="button" class="btn btn-primary btn-sm btn-block" (click)="isCollapsed = !isCollapsed"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapseLCReg">
<b>ID: {{data.feature.ID.value}}</b>
</button>
</div>
</div>
<div id="collapseLCReg" [collapse]="!isCollapsed">
<div>
<pb-info-column [columnConfig]="column_DOtQSConfig" [feature]="data.feature" class="multilabelrow col-12 default-topbtm-padding">
</pb-info-column>
<pb-info-column [columnConfig]="column_gjzMQConfig" [feature]="data.feature" class="multilabelrow col-12 default-topbtm-padding">
</pb-info-column>
<pb-info-column [columnConfig]="column_qEQ3eConfig" [feature]="data.feature" class="multilabelrow col-12 default-topbtm-padding">
</pb-info-column>
<pb-info-column [columnConfig]="column_S86CbConfig" [feature]="data.feature" class="multilabelrow col-12 default-topbtm-padding">
</pb-info-column>
<div class = "multilabelrow col-xs-12 default-topbtm-padding">
<a href ="{{data.feature.REGISTER_ENTRY.value}}" target="_blank">Register Entry link</a>
</div>
<div class = "multilabelrow col-xs-12 default-topbtm-padding">
<a href ="{{data.feature.DOCUMENT.value}}" target="_blank">Document link</a>
</div>
</div>
</div>
------------------------------
Andrew Patterson
Hoople Ltd
Hereford
------------------------------