diff --git a/src/app/components/editor.component.ts b/src/app/components/editor.component.ts
index 0f6ad9d..acf2d4e 100644
--- a/src/app/components/editor.component.ts
+++ b/src/app/components/editor.component.ts
@@ -2,20 +2,18 @@ import { Component, ViewContainerRef, ViewChild, AfterViewInit } from '@angular/
import { AgEditorComponent } from 'ag-grid-ng2/main';
-import { RegionSelectList } from '../models/regionselectlist';
-
@Component({
selector: 'editor-cell',
template: `
-
{{item.name}}
+
{{item[this.params.labelCol]}}
`
})
export class EditorComponent implements AgEditorComponent, AfterViewInit {
@ViewChild('container', {read: ViewContainerRef}) public container;
- public item: any;
- public data: RegionSelectList[];
+ public item: Object = null;
+ public data: Object[];
private params: any;
ngAfterViewInit() {
this.container.element.nativeElement.focus();
@@ -23,8 +21,13 @@ export class EditorComponent implements AgEditorComponent, AfterViewInit {
agInit(params: any): void {
this.params = params;
+ if (!this.params.valueCol) {
+ this.params.valueCol = 'id';
+ }
+ if (!this.params.labelCol) {
+ this.params.labelCol = 'name';
+ }
this.data = params.data || [];
- // this.setHappy(params.value === "Happy");
}
getValue(): any {
@@ -35,11 +38,11 @@ export class EditorComponent implements AgEditorComponent, AfterViewInit {
return true;
}
- setValue(item: any): void {
+ setValue(item: Object): void {
this.item = item;
}
- onClick(item: any) {
+ onClick(item: Object) {
this.setValue(item);
this.params.api.stopEditing();
}
diff --git a/src/app/components/renderer.component.ts b/src/app/components/renderer.component.ts
index c59be85..e1fa5cb 100644
--- a/src/app/components/renderer.component.ts
+++ b/src/app/components/renderer.component.ts
@@ -6,23 +6,28 @@ import { RegionSelectList } from '../models/regionselectlist';
@Component({
selector: 'render-cell',
- template: `{{this.region.name}}`
+ template: `{{this.model[this.labelCol]}}`
})
export class RendererComponent implements AgRendererComponent {
private params: any;
- private region: RegionSelectList;
+ private valueCol: string = 'id';
+ private labelCol: string = 'name';
+ private model: Object = null;
agInit(params: any): void {
this.params = params;
- console.log(params);
+ if (params.colDef.cellEditorParams && params.colDef.cellEditorParams.valueCol) {
+ this.valueCol = params.colDef.cellEditorParams.valueCol;
+ }
+ if (params.colDef.cellEditorParams && params.colDef.cellEditorParams.labelCol) {
+ this.labelCol = params.colDef.cellEditorParams.labelCol;
+ }
this.setValue(params);
}
refresh(params: any): void {
this.params = params;
- console.log(params);
this.setValue(params);
}
private setValue(params) {
- this.region = params.value;
- console.log(params);
+ this.model = params.value;
}
}
diff --git a/src/app/pages/statements/components/busStop2/busStop2.component.ts b/src/app/pages/statements/components/busStop2/busStop2.component.ts
index 252ee2b..af702ea 100644
--- a/src/app/pages/statements/components/busStop2/busStop2.component.ts
+++ b/src/app/pages/statements/components/busStop2/busStop2.component.ts
@@ -85,7 +85,9 @@ export class BusStop2 {
cellEditorFramework: EditorComponent,
cellRendererFramework: RendererComponent,
cellEditorParams: {
- data: this.regions
+ data: this.regions,
+ valueCol: 'regionId',
+ labelCol: 'name'
}
},
{
--
libgit2 0.21.4