Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit c10b4aa

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
add few inline editors & example page, also finished the onCellClick callback in the grid options
1 parent d148b20 commit c10b4aa

40 files changed

+743
-77
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@types/moment": "^2.13.0",
4848
"bootstrap": "^3.3.7",
4949
"core-js": "^2.5.1",
50+
"flatpickr": "^4.0.6",
5051
"font-awesome": "^4.7.0",
5152
"graphql-query-builder": "^1.0.7",
5253
"jquery": "^3.2.1",

src/app/app-routing.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { GridBasicComponent } from './examples/grid-basic.component';
22
import { GridClientSideComponent } from './examples/grid-clientside.component';
3+
import { GridEditorComponent } from './examples/grid-editor.component';
34
import { GridFormatterComponent } from './examples/grid-formatter.component';
45
import { GridOdataComponent } from './examples/grid-odata.component';
56
import { GridGraphqlComponent } from './examples/grid-graphql.component';
@@ -8,6 +9,7 @@ import { Routes, RouterModule } from '@angular/router';
89

910
const routes: Routes = [
1011
{ path: 'basic', component: GridBasicComponent },
12+
{ path: 'editor', component: GridEditorComponent },
1113
{ path: 'formatter', component: GridFormatterComponent },
1214
{ path: 'clientside', component: GridClientSideComponent },
1315
{ path: 'odata', component: GridOdataComponent },

src/app/app.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
<a [routerLink]="['/basic']">Basic Grid</a>
2121
</li>
2222
<li routerLinkActive="active">
23-
<a [routerLink]="['/formatter']">Formatter</a>
23+
<a [routerLink]="['/editor']">Editors</a>
24+
</li>
25+
<li routerLinkActive="active">
26+
<a [routerLink]="['/formatter']">Formatters</a>
2427
</li>
2528
<li routerLinkActive="active">
2629
<a [routerLink]="['/clientside']">Client Side Sort/Filter</a>

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { NgModule } from '@angular/core';
77
import { AppComponent } from './app.component';
88
import { GridBasicComponent } from './examples/grid-basic.component';
99
import { GridClientSideComponent } from './examples/grid-clientside.component';
10+
import { GridEditorComponent } from './examples/grid-editor.component';
1011
import { GridFormatterComponent } from './examples/grid-formatter.component';
1112
import { GridOdataComponent } from './examples/grid-odata.component';
1213
import { GridGraphqlComponent } from './examples/grid-graphql.component';
@@ -21,6 +22,7 @@ import { AngularSlickgridModule } from './modules/angular-slickgrid/modules/angu
2122
AppComponent,
2223
GridBasicComponent,
2324
GridClientSideComponent,
25+
GridEditorComponent,
2426
GridFormatterComponent,
2527
GridOdataComponent,
2628
GridGraphqlComponent

src/app/examples/grid-basic.component.scss

Whitespace-only changes.

src/app/examples/grid-basic.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { Column, GridOption } from './../modules/angular-slickgrid/models';
55
declare var Slick: any;
66

77
@Component({
8-
templateUrl: './grid-basic.component.html',
9-
styleUrls: ['./grid-basic.component.scss']
8+
templateUrl: './grid-basic.component.html'
109
})
1110
export class GridBasicComponent implements OnInit {
1211
title = 'Basic Grid';
@@ -29,7 +28,7 @@ export class GridBasicComponent implements OnInit {
2928
enableAutoResize: false
3029
};
3130

32-
// fake a dataset
31+
// mock a dataset
3332
this.dataset = [];
3433
for (let i = 0; i < 1000; i++) {
3534
const randomYear = 2000 + Math.floor(Math.random() * 10);

src/app/examples/grid-clientside.component.scss

Whitespace-only changes.

src/app/examples/grid-clientside.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ function randomBetween(min, max) {
77
}
88

99
@Component({
10-
templateUrl: './grid-clientside.component.html',
11-
styleUrls: ['./grid-clientside.component.scss']
10+
templateUrl: './grid-clientside.component.html'
1211
})
1312
export class GridClientSideComponent implements OnInit {
1413
title = 'Client Side Sort/Filter';
@@ -63,7 +62,7 @@ export class GridClientSideComponent implements OnInit {
6362
enableCellNavigation: true
6463
};
6564

66-
// fake a dataset
65+
// mock a dataset
6766
this.dataset = [];
6867
for (let i = 0; i < 1000; i++) {
6968
const randomYear = randomBetween(2000, 2025);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--The content below is only a placeholder and can be replaced.-->
2+
<div class="container">
3+
<h2>{{title}}</h2>
4+
<div class="subtitle" [innerHTML]="subTitle"></div>
5+
6+
<angular-slickgrid gridId="grid2"
7+
[columnDefinitions]="columnDefinitions"
8+
[gridOptions]="gridOptions"
9+
[dataset]="dataset">
10+
</angular-slickgrid>
11+
</div>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Editors, Formatters } from './../modules/angular-slickgrid';
3+
import { OnCellClickArgs, Column, FieldType, Formatter, GridOption } from './../modules/angular-slickgrid/models';
4+
5+
@Component({
6+
templateUrl: './grid-formatter.component.html'
7+
})
8+
export class GridEditorComponent implements OnInit {
9+
title = 'Example 4: Editors';
10+
subTitle = `inline editors (not yet implement) and onCellClick editor (execute an action, e.g: open a modal window)`;
11+
12+
columnDefinitions: Column[];
13+
gridOptions: GridOption;
14+
dataset: any[];
15+
16+
ngOnInit(): void {
17+
this.columnDefinitions = [
18+
{ id: 'id', field: 'id',
19+
formatter: Formatters.editPencil,
20+
maxWidth: 30,
21+
onCellClick: (args: OnCellClickArgs) => {
22+
console.log(args);
23+
console.log(this);
24+
}
25+
},
26+
{ id: 'title', name: 'Title', field: 'title', sortable: true, type: FieldType.string, editor: Editors.longText },
27+
{ id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true, type: FieldType.number, editor: Editors.text },
28+
{ id: 'complete', name: '% Complete', field: 'percentComplete', formatter: Formatters.percentCompleteBar, type: FieldType.number, editor: Editors.integer, sortable: true },
29+
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, sortable: true, type: FieldType.dateIso, editor: Editors.date },
30+
{ id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso, sortable: true, type: FieldType.date },
31+
{ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', formatter: Formatters.checkmark, type: FieldType.number, sortable: true }
32+
];
33+
34+
this.gridOptions = {
35+
autoResize: {
36+
containerId: 'demo-container',
37+
sidePadding: 15
38+
},
39+
editable: true,
40+
enableCellNavigation: true,
41+
asyncEditorLoading: false,
42+
autoEdit: true
43+
};
44+
45+
// mock a dataset
46+
this.dataset = [];
47+
for (let i = 0; i < 5; i++) {
48+
const randomYear = 2000 + Math.floor(Math.random() * 10);
49+
const randomMonth = Math.floor(Math.random() * 11);
50+
const randomDay = Math.floor((Math.random() * 29));
51+
const randomPercent = Math.round(Math.random() * 100);
52+
53+
this.dataset[i] = {
54+
id: i,
55+
title: 'Task ' + i,
56+
duration: Math.round(Math.random() * 100) + '',
57+
percentComplete: randomPercent,
58+
percentCompleteNumber: randomPercent,
59+
start: new Date(randomYear, randomMonth, randomDay),
60+
finish: new Date(randomYear, (randomMonth + 1), randomDay),
61+
effortDriven: (i % 5 === 0)
62+
};
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)