ag-grid-aurelia-plugin 31.3.8 → 31.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -28
- package/lib/agGridAurelia.d.ts +33 -33
- package/lib/agGridAurelia.js +163 -163
- package/lib/agGridColumn.d.ts +18 -18
- package/lib/agGridColumn.js +155 -155
- package/lib/agTemplate.d.ts +34 -34
- package/lib/agTemplate.js +142 -142
- package/lib/agUtils.d.ts +2 -2
- package/lib/agUtils.js +22 -22
- package/lib/aureliaFrameworkComponentWrapper.d.ts +13 -13
- package/lib/aureliaFrameworkComponentWrapper.js +112 -112
- package/lib/aureliaFrameworkFactory.d.ts +20 -20
- package/lib/aureliaFrameworkFactory.js +53 -53
- package/main.d.ts +4 -4
- package/main.js +19 -19
- package/package.json +7 -4
- package/src/agGridAurelia.ts +9 -9
- package/src/agGridColumn.ts +6 -6
- package/src/agTemplate.ts +10 -10
- package/src/agUtils.ts +2 -2
- package/src/aureliaFrameworkComponentWrapper.ts +1 -1
- package/src/aureliaFrameworkFactory.ts +2 -5
package/README.md
CHANGED
|
@@ -1,49 +1,54 @@
|
|
|
1
1
|
ag-Grid Aurelia Component
|
|
2
2
|
==============
|
|
3
3
|
|
|
4
|
-
This project contains the Aurelia Component for use with ag-Grid.
|
|
4
|
+
This project contains the Aurelia Component for use with ag-Grid Community Edition.
|
|
5
5
|
|
|
6
6
|
Usage
|
|
7
7
|
==============
|
|
8
8
|
|
|
9
|
-
Please refer to www.ag-grid.com for full documentation on ag-Grid and Aurelia integration. Also take a look a the provided examples
|
|
9
|
+
Please refer to www.ag-grid.com for full documentation on ag-Grid and Aurelia integration. Also take a look a the provided examples below.
|
|
10
10
|
|
|
11
11
|
Frameworks Supported
|
|
12
12
|
====================
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[
|
|
16
|
-
|
|
13
|
+
Migration and Getting Started guides:
|
|
14
|
+
|
|
15
|
+
[Migration Guide](https://www.ag-grid.com/javascript-data-grid/migration/)
|
|
16
|
+
|
|
17
|
+
[API Reference](https://www.ag-grid.com/javascript-data-grid/reference/)
|
|
18
|
+
|
|
19
|
+
[Docs](https://www.ag-grid.com/javascript-data-grid/getting-started/)
|
|
17
20
|
|
|
18
21
|
In your main entry.
|
|
19
22
|
```
|
|
20
23
|
aurelia.use
|
|
21
24
|
.standardConfiguration()
|
|
22
|
-
.plugin('ag-grid-aurelia');
|
|
25
|
+
.plugin('ag-grid-aurelia-plugin');
|
|
23
26
|
```
|
|
24
27
|
|
|
25
28
|
In your view model
|
|
26
29
|
```
|
|
27
|
-
import {GridOptions} from 'ag-grid';
|
|
28
30
|
export class MyGridPage {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
gridOptions = {
|
|
32
|
+
onGridReady: params => {
|
|
33
|
+
console.log('Grid is ready!!');
|
|
34
|
+
console.log('1st col field = ' + this.gridOptions.columnDefs[0].field);
|
|
35
|
+
this.api = params.api;
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.log('1st col field = ' + this.gridOptions.columnDefs[0].field);
|
|
38
|
+
|
|
39
|
+
bind() {
|
|
40
|
+
this.api.setGridOption('rowData', [{id: 1, name: 'Shane'}, {id: 2, name: 'Sean'}]);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
onIdClicked(row){
|
|
43
44
|
console.log('id clicked ' + row.id);
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
onGridReady() {
|
|
48
|
+
console.log('Grid is ready!!');
|
|
49
|
+
console.log('1st col field = ' + this.gridOptions.columnDefs[0].field);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
47
52
|
|
|
48
53
|
```
|
|
49
54
|
In your view template. Here we are adding columns using markup. ColumnDefs can be added from your view model if you wish.
|
|
@@ -53,6 +58,7 @@ In your view template. Here we are adding columns using markup. ColumnDefs can
|
|
|
53
58
|
<ag-grid-aurelia grid-options.bind="gridOptions" class="ag-material"
|
|
54
59
|
row-height.bind="48"
|
|
55
60
|
grid-ready.call="onGridReady()">
|
|
61
|
+
|
|
56
62
|
<ag-grid-column header-name="My Group Column">
|
|
57
63
|
<ag-grid-column header-name="Id" field="id">
|
|
58
64
|
<ag-cell-template>
|
|
@@ -62,7 +68,6 @@ In your view template. Here we are adding columns using markup. ColumnDefs can
|
|
|
62
68
|
<ag-grid-column header-name="Name" field="name" >
|
|
63
69
|
</ag-grid-column>
|
|
64
70
|
</ag-grid-column>
|
|
65
|
-
|
|
66
71
|
</ag-grid-aurelia>
|
|
67
72
|
</div>
|
|
68
73
|
|
|
@@ -74,10 +79,8 @@ Building
|
|
|
74
79
|
|
|
75
80
|
To build:
|
|
76
81
|
- npm install
|
|
77
|
-
- npm install gulp -g
|
|
78
|
-
- npm install aurelia-framework
|
|
79
|
-
- npm install ag-grid
|
|
80
|
-
- (or: npm install aurelia-framework@1.0.x && npm install ag-grid@13.0.2)
|
|
81
|
-
|
|
82
82
|
- npm run build
|
|
83
|
-
|
|
83
|
+
|
|
84
|
+
To develop:
|
|
85
|
+
- npm install
|
|
86
|
+
- npm run watch
|
package/lib/agGridAurelia.d.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
// ag-grid-aurelia-plugin v31.3.
|
|
2
|
-
import type { GridApi, GridOptions } from "ag-grid-community";
|
|
3
|
-
import { ComponentAttached, ComponentDetached, Container, TaskQueue, ViewResources } from "aurelia-framework";
|
|
4
|
-
import { AureliaFrameworkFactory } from "./aureliaFrameworkFactory";
|
|
5
|
-
import { AgGridColumn } from "./agGridColumn";
|
|
6
|
-
import { AgDateTemplate, AgFullWidthRowTemplate } from './agTemplate';
|
|
7
|
-
import { AureliaFrameworkComponentWrapper } from "./aureliaFrameworkComponentWrapper";
|
|
8
|
-
export declare class AgGridAurelia implements ComponentAttached, ComponentDetached {
|
|
9
|
-
private taskQueue;
|
|
10
|
-
private auFrameworkFactory;
|
|
11
|
-
private container;
|
|
12
|
-
private viewResources;
|
|
13
|
-
private aureliaFrameworkComponentWrapper;
|
|
14
|
-
private _nativeElement;
|
|
15
|
-
private _initialised;
|
|
16
|
-
private _destroyed;
|
|
17
|
-
gridOptions: GridOptions;
|
|
18
|
-
context: any;
|
|
19
|
-
private gridParams;
|
|
20
|
-
api: GridApi;
|
|
21
|
-
columns: AgGridColumn[];
|
|
22
|
-
fullWidthRowTemplate: AgFullWidthRowTemplate;
|
|
23
|
-
dateTemplate: AgDateTemplate;
|
|
24
|
-
constructor(element: Element, taskQueue: TaskQueue, auFrameworkFactory: AureliaFrameworkFactory, container: Container, viewResources: ViewResources, aureliaFrameworkComponentWrapper: AureliaFrameworkComponentWrapper);
|
|
25
|
-
attached(): void;
|
|
26
|
-
initGrid(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Called by Aurelia whenever a bound property changes
|
|
29
|
-
*/
|
|
30
|
-
propertyChanged(propertyName: string, newValue: any, oldValue: any): void;
|
|
31
|
-
detached(): void;
|
|
32
|
-
private globalEventListener;
|
|
33
|
-
}
|
|
1
|
+
// ag-grid-aurelia-plugin v31.3.10
|
|
2
|
+
import type { GridApi, GridOptions } from "ag-grid-community";
|
|
3
|
+
import { ComponentAttached, ComponentDetached, Container, TaskQueue, ViewResources } from "aurelia-framework";
|
|
4
|
+
import { AureliaFrameworkFactory } from "./aureliaFrameworkFactory";
|
|
5
|
+
import { AgGridColumn } from "./agGridColumn";
|
|
6
|
+
import { AgDateTemplate, AgFullWidthRowTemplate } from './agTemplate';
|
|
7
|
+
import { AureliaFrameworkComponentWrapper } from "./aureliaFrameworkComponentWrapper";
|
|
8
|
+
export declare class AgGridAurelia implements ComponentAttached, ComponentDetached {
|
|
9
|
+
private taskQueue;
|
|
10
|
+
private auFrameworkFactory;
|
|
11
|
+
private container;
|
|
12
|
+
private viewResources;
|
|
13
|
+
private aureliaFrameworkComponentWrapper;
|
|
14
|
+
private _nativeElement;
|
|
15
|
+
private _initialised;
|
|
16
|
+
private _destroyed;
|
|
17
|
+
gridOptions: GridOptions;
|
|
18
|
+
context: any;
|
|
19
|
+
private gridParams;
|
|
20
|
+
api: GridApi;
|
|
21
|
+
columns: AgGridColumn[];
|
|
22
|
+
fullWidthRowTemplate: AgFullWidthRowTemplate;
|
|
23
|
+
dateTemplate: AgDateTemplate;
|
|
24
|
+
constructor(element: Element, taskQueue: TaskQueue, auFrameworkFactory: AureliaFrameworkFactory, container: Container, viewResources: ViewResources, aureliaFrameworkComponentWrapper: AureliaFrameworkComponentWrapper);
|
|
25
|
+
attached(): void;
|
|
26
|
+
initGrid(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Called by Aurelia whenever a bound property changes
|
|
29
|
+
*/
|
|
30
|
+
propertyChanged(propertyName: string, newValue: any, oldValue: any): void;
|
|
31
|
+
detached(): void;
|
|
32
|
+
private globalEventListener;
|
|
33
|
+
}
|
package/lib/agGridAurelia.js
CHANGED
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
// ag-grid-aurelia-plugin v31.3.
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
import { autoinject, bindable, child, children, Container, customElement, inlineView, TaskQueue, ViewResources } from "aurelia-framework";
|
|
12
|
-
import { ComponentUtil, createGrid } from "ag-grid-community";
|
|
13
|
-
import { AureliaFrameworkFactory } from "./aureliaFrameworkFactory";
|
|
14
|
-
import { generateBindables } from "./agUtils";
|
|
15
|
-
import { AgDateTemplate, AgFullWidthRowTemplate } from './agTemplate';
|
|
16
|
-
import { AureliaFrameworkComponentWrapper } from "./aureliaFrameworkComponentWrapper";
|
|
17
|
-
let AgGridAurelia = class AgGridAurelia {
|
|
18
|
-
taskQueue;
|
|
19
|
-
auFrameworkFactory;
|
|
20
|
-
container;
|
|
21
|
-
viewResources;
|
|
22
|
-
aureliaFrameworkComponentWrapper;
|
|
23
|
-
// not intended for user to interact with. so putting _ in so if user gets reference
|
|
24
|
-
// to this object, they kind'a know it's not part of the agreed interface
|
|
25
|
-
_nativeElement;
|
|
26
|
-
_initialised = false;
|
|
27
|
-
_destroyed = false;
|
|
28
|
-
gridOptions;
|
|
29
|
-
context;
|
|
30
|
-
gridParams;
|
|
31
|
-
// making these public, so they are accessible to people using the aurelia component references
|
|
32
|
-
api;
|
|
33
|
-
columns = [];
|
|
34
|
-
fullWidthRowTemplate;
|
|
35
|
-
dateTemplate;
|
|
36
|
-
constructor(element, taskQueue, auFrameworkFactory, container, viewResources, aureliaFrameworkComponentWrapper) {
|
|
37
|
-
this.taskQueue = taskQueue;
|
|
38
|
-
this.auFrameworkFactory = auFrameworkFactory;
|
|
39
|
-
this.container = container;
|
|
40
|
-
this.viewResources = viewResources;
|
|
41
|
-
this.aureliaFrameworkComponentWrapper = aureliaFrameworkComponentWrapper;
|
|
42
|
-
this._nativeElement = element;
|
|
43
|
-
// create all the events generically. this is done generically so that
|
|
44
|
-
// if the list of grid events change, we don't need to change this code.
|
|
45
|
-
ComponentUtil.EVENTS.forEach((eventName) => {
|
|
46
|
-
//create an empty event
|
|
47
|
-
this[eventName] = () => {
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
attached() {
|
|
52
|
-
// initialize the grid in the queue
|
|
53
|
-
// because of bug in @children
|
|
54
|
-
// https://github.com/aurelia/templating/issues/403
|
|
55
|
-
this.taskQueue.queueTask(this.initGrid.bind(this));
|
|
56
|
-
}
|
|
57
|
-
initGrid() {
|
|
58
|
-
this._initialised = false;
|
|
59
|
-
this._destroyed = false;
|
|
60
|
-
this.auFrameworkFactory.setContainer(this.container);
|
|
61
|
-
this.auFrameworkFactory.setViewResources(this.viewResources);
|
|
62
|
-
this.aureliaFrameworkComponentWrapper.setContainer(this.container);
|
|
63
|
-
this.aureliaFrameworkComponentWrapper.setViewResources(this.viewResources);
|
|
64
|
-
this.gridOptions = ComponentUtil.combineAttributesAndGridOptions(this.gridOptions, this);
|
|
65
|
-
this.gridParams = {
|
|
66
|
-
globalEventListener: this.globalEventListener.bind(this),
|
|
67
|
-
frameworkFactory: this.auFrameworkFactory,
|
|
68
|
-
seedBeanInstances: {
|
|
69
|
-
frameworkComponentWrapper: this.aureliaFrameworkComponentWrapper
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
if (this.columns && this.columns.length > 0) {
|
|
73
|
-
this.gridOptions.columnDefs = this.columns
|
|
74
|
-
.map((column) => {
|
|
75
|
-
return column.toColDef();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (this.fullWidthRowTemplate) {
|
|
79
|
-
this.gridOptions.fullWidthCellRenderer =
|
|
80
|
-
{ template: this.fullWidthRowTemplate.template };
|
|
81
|
-
}
|
|
82
|
-
if (this.dateTemplate) {
|
|
83
|
-
this.gridOptions.dataTypeDefinitions = {
|
|
84
|
-
date: {
|
|
85
|
-
baseDataType: 'date',
|
|
86
|
-
extendsDataType: 'date',
|
|
87
|
-
valueFormatter: () => this.dateTemplate.template
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
this.api = createGrid(this._nativeElement, this.gridOptions, this.gridParams);
|
|
92
|
-
this._initialised = true;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Called by Aurelia whenever a bound property changes
|
|
96
|
-
*/
|
|
97
|
-
propertyChanged(propertyName, newValue, oldValue) {
|
|
98
|
-
// emulate an Angular2 SimpleChanges Object
|
|
99
|
-
let changes = {};
|
|
100
|
-
changes[propertyName] = { currentValue: newValue, previousValue: oldValue };
|
|
101
|
-
if (this._initialised) {
|
|
102
|
-
ComponentUtil.processOnChange(changes, this.api);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
detached() {
|
|
106
|
-
if (this._initialised) {
|
|
107
|
-
// need to do this before the destroy, so we know not to emit any events
|
|
108
|
-
// while tearing down the grid.
|
|
109
|
-
this._destroyed = true;
|
|
110
|
-
this.api.destroy();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
globalEventListener(eventType, event) {
|
|
114
|
-
// if we are tearing down, don't emit events
|
|
115
|
-
if (this._destroyed) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
// generically look up the eventType
|
|
119
|
-
let emitter = this[eventType];
|
|
120
|
-
if (emitter) {
|
|
121
|
-
emitter(event);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
console.log('ag-Grid-aurelia: could not find EventEmitter: ' + eventType);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
__decorate([
|
|
129
|
-
bindable(),
|
|
130
|
-
__metadata("design:type", Object)
|
|
131
|
-
], AgGridAurelia.prototype, "gridOptions", void 0);
|
|
132
|
-
__decorate([
|
|
133
|
-
bindable(),
|
|
134
|
-
__metadata("design:type", Object)
|
|
135
|
-
], AgGridAurelia.prototype, "context", void 0);
|
|
136
|
-
__decorate([
|
|
137
|
-
children('ag-grid-column'),
|
|
138
|
-
__metadata("design:type", Array)
|
|
139
|
-
], AgGridAurelia.prototype, "columns", void 0);
|
|
140
|
-
__decorate([
|
|
141
|
-
child('ag-full-width-row-template'),
|
|
142
|
-
__metadata("design:type", AgFullWidthRowTemplate)
|
|
143
|
-
], AgGridAurelia.prototype, "fullWidthRowTemplate", void 0);
|
|
144
|
-
__decorate([
|
|
145
|
-
child('ag-date-template'),
|
|
146
|
-
__metadata("design:type", AgDateTemplate)
|
|
147
|
-
], AgGridAurelia.prototype, "dateTemplate", void 0);
|
|
148
|
-
AgGridAurelia = __decorate([
|
|
149
|
-
customElement('ag-grid-aurelia'),
|
|
150
|
-
generateBindables(ComponentUtil.ALL_PROPERTIES.filter((property) => property !== 'gridOptions')),
|
|
151
|
-
generateBindables(ComponentUtil.EVENTS)
|
|
152
|
-
// <slot> is required for @children to work. https://github.com/aurelia/templating/issues/451#issuecomment-254206622
|
|
153
|
-
,
|
|
154
|
-
inlineView(`<template><slot></slot></template>`),
|
|
155
|
-
autoinject(),
|
|
156
|
-
__metadata("design:paramtypes", [Element,
|
|
157
|
-
TaskQueue,
|
|
158
|
-
AureliaFrameworkFactory,
|
|
159
|
-
Container,
|
|
160
|
-
ViewResources,
|
|
161
|
-
AureliaFrameworkComponentWrapper])
|
|
162
|
-
], AgGridAurelia);
|
|
163
|
-
export { AgGridAurelia };
|
|
1
|
+
// ag-grid-aurelia-plugin v31.3.10
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
import { autoinject, bindable, child, children, Container, customElement, inlineView, TaskQueue, ViewResources, } from "aurelia-framework";
|
|
12
|
+
import { ComponentUtil, createGrid } from "ag-grid-community-v31";
|
|
13
|
+
import { AureliaFrameworkFactory } from "./aureliaFrameworkFactory";
|
|
14
|
+
import { generateBindables } from "./agUtils";
|
|
15
|
+
import { AgDateTemplate, AgFullWidthRowTemplate } from './agTemplate';
|
|
16
|
+
import { AureliaFrameworkComponentWrapper } from "./aureliaFrameworkComponentWrapper";
|
|
17
|
+
let AgGridAurelia = class AgGridAurelia {
|
|
18
|
+
taskQueue;
|
|
19
|
+
auFrameworkFactory;
|
|
20
|
+
container;
|
|
21
|
+
viewResources;
|
|
22
|
+
aureliaFrameworkComponentWrapper;
|
|
23
|
+
// not intended for user to interact with. so putting _ in so if user gets reference
|
|
24
|
+
// to this object, they kind'a know it's not part of the agreed interface
|
|
25
|
+
_nativeElement;
|
|
26
|
+
_initialised = false;
|
|
27
|
+
_destroyed = false;
|
|
28
|
+
gridOptions;
|
|
29
|
+
context;
|
|
30
|
+
gridParams;
|
|
31
|
+
// making these public, so they are accessible to people using the aurelia component references
|
|
32
|
+
api;
|
|
33
|
+
columns = [];
|
|
34
|
+
fullWidthRowTemplate;
|
|
35
|
+
dateTemplate;
|
|
36
|
+
constructor(element, taskQueue, auFrameworkFactory, container, viewResources, aureliaFrameworkComponentWrapper) {
|
|
37
|
+
this.taskQueue = taskQueue;
|
|
38
|
+
this.auFrameworkFactory = auFrameworkFactory;
|
|
39
|
+
this.container = container;
|
|
40
|
+
this.viewResources = viewResources;
|
|
41
|
+
this.aureliaFrameworkComponentWrapper = aureliaFrameworkComponentWrapper;
|
|
42
|
+
this._nativeElement = element;
|
|
43
|
+
// create all the events generically. this is done generically so that
|
|
44
|
+
// if the list of grid events change, we don't need to change this code.
|
|
45
|
+
ComponentUtil.EVENTS.forEach((eventName) => {
|
|
46
|
+
//create an empty event
|
|
47
|
+
this[eventName] = () => {
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
attached() {
|
|
52
|
+
// initialize the grid in the queue
|
|
53
|
+
// because of bug in @children
|
|
54
|
+
// https://github.com/aurelia/templating/issues/403
|
|
55
|
+
this.taskQueue.queueTask(this.initGrid.bind(this));
|
|
56
|
+
}
|
|
57
|
+
initGrid() {
|
|
58
|
+
this._initialised = false;
|
|
59
|
+
this._destroyed = false;
|
|
60
|
+
this.auFrameworkFactory.setContainer(this.container);
|
|
61
|
+
this.auFrameworkFactory.setViewResources(this.viewResources);
|
|
62
|
+
this.aureliaFrameworkComponentWrapper.setContainer(this.container);
|
|
63
|
+
this.aureliaFrameworkComponentWrapper.setViewResources(this.viewResources);
|
|
64
|
+
this.gridOptions = ComponentUtil.combineAttributesAndGridOptions(this.gridOptions, this);
|
|
65
|
+
this.gridParams = {
|
|
66
|
+
globalEventListener: this.globalEventListener.bind(this),
|
|
67
|
+
frameworkFactory: this.auFrameworkFactory,
|
|
68
|
+
seedBeanInstances: {
|
|
69
|
+
frameworkComponentWrapper: this.aureliaFrameworkComponentWrapper
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (this.columns && this.columns.length > 0) {
|
|
73
|
+
this.gridOptions.columnDefs = this.columns
|
|
74
|
+
.map((column) => {
|
|
75
|
+
return column.toColDef();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (this.fullWidthRowTemplate) {
|
|
79
|
+
this.gridOptions.fullWidthCellRenderer =
|
|
80
|
+
{ template: this.fullWidthRowTemplate.template };
|
|
81
|
+
}
|
|
82
|
+
if (this.dateTemplate) {
|
|
83
|
+
this.gridOptions.dataTypeDefinitions = {
|
|
84
|
+
date: {
|
|
85
|
+
baseDataType: 'date',
|
|
86
|
+
extendsDataType: 'date',
|
|
87
|
+
valueFormatter: () => this.dateTemplate.template
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
this.api = createGrid(this._nativeElement, this.gridOptions, this.gridParams);
|
|
92
|
+
this._initialised = true;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Called by Aurelia whenever a bound property changes
|
|
96
|
+
*/
|
|
97
|
+
propertyChanged(propertyName, newValue, oldValue) {
|
|
98
|
+
// emulate an Angular2 SimpleChanges Object
|
|
99
|
+
let changes = {};
|
|
100
|
+
changes[propertyName] = { currentValue: newValue, previousValue: oldValue };
|
|
101
|
+
if (this._initialised) {
|
|
102
|
+
ComponentUtil.processOnChange(changes, this.api);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
detached() {
|
|
106
|
+
if (this._initialised) {
|
|
107
|
+
// need to do this before the destroy, so we know not to emit any events
|
|
108
|
+
// while tearing down the grid.
|
|
109
|
+
this._destroyed = true;
|
|
110
|
+
this.api.destroy();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
globalEventListener(eventType, event) {
|
|
114
|
+
// if we are tearing down, don't emit events
|
|
115
|
+
if (this._destroyed) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// generically look up the eventType
|
|
119
|
+
let emitter = this[eventType];
|
|
120
|
+
if (emitter) {
|
|
121
|
+
emitter(event);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.log('ag-Grid-aurelia: could not find EventEmitter: ' + eventType);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
__decorate([
|
|
129
|
+
bindable(),
|
|
130
|
+
__metadata("design:type", Object)
|
|
131
|
+
], AgGridAurelia.prototype, "gridOptions", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
bindable(),
|
|
134
|
+
__metadata("design:type", Object)
|
|
135
|
+
], AgGridAurelia.prototype, "context", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
children('ag-grid-column'),
|
|
138
|
+
__metadata("design:type", Array)
|
|
139
|
+
], AgGridAurelia.prototype, "columns", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
child('ag-full-width-row-template'),
|
|
142
|
+
__metadata("design:type", AgFullWidthRowTemplate)
|
|
143
|
+
], AgGridAurelia.prototype, "fullWidthRowTemplate", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
child('ag-date-template'),
|
|
146
|
+
__metadata("design:type", AgDateTemplate)
|
|
147
|
+
], AgGridAurelia.prototype, "dateTemplate", void 0);
|
|
148
|
+
AgGridAurelia = __decorate([
|
|
149
|
+
customElement('ag-grid-aurelia-m3'),
|
|
150
|
+
generateBindables(ComponentUtil.ALL_PROPERTIES.filter((property) => property !== 'gridOptions')),
|
|
151
|
+
generateBindables(ComponentUtil.EVENTS)
|
|
152
|
+
// <slot> is required for @children to work. https://github.com/aurelia/templating/issues/451#issuecomment-254206622
|
|
153
|
+
,
|
|
154
|
+
inlineView(`<template><slot></slot></template>`),
|
|
155
|
+
autoinject(),
|
|
156
|
+
__metadata("design:paramtypes", [Element,
|
|
157
|
+
TaskQueue,
|
|
158
|
+
AureliaFrameworkFactory,
|
|
159
|
+
Container,
|
|
160
|
+
ViewResources,
|
|
161
|
+
AureliaFrameworkComponentWrapper])
|
|
162
|
+
], AgGridAurelia);
|
|
163
|
+
export { AgGridAurelia };
|
package/lib/agGridColumn.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// ag-grid-aurelia-plugin v31.3.
|
|
2
|
-
import { ColDef } from "ag-grid-community";
|
|
3
|
-
import { AgCellTemplate, AgEditorTemplate, AgFilterTemplate, AgHeaderGroupTemplate, AgHeaderTemplate, AgPinnedRowTemplate } from "./agTemplate";
|
|
4
|
-
export declare class AgGridColumn {
|
|
5
|
-
private mappedColumnProperties;
|
|
6
|
-
childColumns: AgGridColumn[];
|
|
7
|
-
cellTemplate: AgCellTemplate;
|
|
8
|
-
editorTemplate: AgEditorTemplate;
|
|
9
|
-
filterTemplate: AgFilterTemplate;
|
|
10
|
-
headerTemplate: AgHeaderTemplate;
|
|
11
|
-
headerGroupTemplate: AgHeaderGroupTemplate;
|
|
12
|
-
pinnedRowTemplate: AgPinnedRowTemplate;
|
|
13
|
-
constructor();
|
|
14
|
-
hasChildColumns(): boolean;
|
|
15
|
-
toColDef(): ColDef;
|
|
16
|
-
private static getChildColDefs;
|
|
17
|
-
private createColDefFromGridColumn;
|
|
18
|
-
}
|
|
1
|
+
// ag-grid-aurelia-plugin v31.3.10
|
|
2
|
+
import { ColDef } from "ag-grid-community-v31";
|
|
3
|
+
import { AgCellTemplate, AgEditorTemplate, AgFilterTemplate, AgHeaderGroupTemplate, AgHeaderTemplate, AgPinnedRowTemplate } from "./agTemplate";
|
|
4
|
+
export declare class AgGridColumn {
|
|
5
|
+
private mappedColumnProperties;
|
|
6
|
+
childColumns: AgGridColumn[];
|
|
7
|
+
cellTemplate: AgCellTemplate;
|
|
8
|
+
editorTemplate: AgEditorTemplate;
|
|
9
|
+
filterTemplate: AgFilterTemplate;
|
|
10
|
+
headerTemplate: AgHeaderTemplate;
|
|
11
|
+
headerGroupTemplate: AgHeaderGroupTemplate;
|
|
12
|
+
pinnedRowTemplate: AgPinnedRowTemplate;
|
|
13
|
+
constructor();
|
|
14
|
+
hasChildColumns(): boolean;
|
|
15
|
+
toColDef(): ColDef;
|
|
16
|
+
private static getChildColDefs;
|
|
17
|
+
private createColDefFromGridColumn;
|
|
18
|
+
}
|