Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb156b5

Browse files
2 parents fddd8b4 + e81dc00 commit bb156b5

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

‎src/AspnetRun.Web/src/app/views/product/product-list/product-list.component.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { Router } from '@angular/router';
23

3-
import { AngularGridInstance, Column, GridOption, FieldType,GraphqlService, GraphqlResult } from 'angular-slickgrid';
4+
import { AngularGridInstance, Column, GridOption, GraphqlService, GraphqlResult,Filters,Formatter,Formatters,OnEventArgs,FieldType } from 'angular-slickgrid';
45

56
import { ProductDataService } from 'src/app/core/services/product-data.service';
67

8+
79
const GRAPHQL_QUERY_DATASET_NAME = 'products';
810

11+
912
@Component({
1013
templateUrl: './product-list.component.html',
1114
styleUrls: ['./product-list.component.css']
@@ -16,15 +19,28 @@ export class ProductListComponent implements OnInit {
1619
gridOptions: GridOption;
1720
dataset = [];
1821

19-
constructor(private dataService: ProductDataService) {
22+
constructor(private dataService: ProductDataService,privaterouter: Router) {
2023
}
2124

2225
ngOnInit(): void {
2326
this.columnDefinitions = [
24-
{ id: 'id', field: 'id', name: 'Id', filterable: true, sortable: true, type: FieldType.number },
25-
{ id: 'name', field: 'name', name: 'Name', filterable: true, sortable: true, type: FieldType.string },
26-
{ id: 'unitPrice', field: 'unitPrice', name: 'Unit Price', filterable: true, sortable: true, type: FieldType.number },
27-
{ id: 'category.id', field: 'category.id', name: 'Category', filterable: true, sortable: true, type: FieldType.string },
27+
{
28+
id: 'edit',
29+
field: 'id',
30+
excludeFromColumnPicker: true,
31+
excludeFromGridMenu: true,
32+
excludeFromHeaderMenu: true,
33+
formatter: Formatters.editIcon,
34+
minWidth: 30,
35+
maxWidth: 30,
36+
onCellClick: (e: Event, args: OnEventArgs) => {
37+
this.router.navigate(['/product/product-detail/' + args.dataContext.id]);
38+
}
39+
},
40+
{ id: 'id', field: 'id', name: 'Id', filterable: true, sortable: true, maxWidth: 200, type: FieldType.number, filter: { model: Filters.inputNumber } },
41+
{ id: 'name', field: 'name', name: 'Name', filterable: true, sortable: true },
42+
{ id: 'unitPrice', field: 'unitPrice', name: 'Unit Price', filterable: true, sortable: true, maxWidth: 200, filter: { model: Filters.inputNumber } },
43+
{ id: 'category', field: 'category.name', name: 'Category', filterable: true, sortable: true, formatter: Formatters.complexObject },
2844
];
2945

3046
this.gridOptions = {
@@ -36,7 +52,7 @@ export class ProductListComponent implements OnInit {
3652
isWithCursor: false,
3753
keepArgumentFieldDoubleQuotes: true
3854
},
39-
process: (query) => this.getProducts(query),
55+
process: (query) => this.getProducts(),
4056
}
4157
};;
4258
}
@@ -45,8 +61,16 @@ export class ProductListComponent implements OnInit {
4561
this.angularGrid = angularGrid;
4662
}
4763

48-
getProducts(query: string): Promise<GraphqlResult> {
49-
return new Promise((resolve, reject) => {
64+
getProducts(): Promise<GraphqlResult> {
65+
66+
if (this.angularGrid) {
67+
var a = this.angularGrid.backendService.getCurrentFilters();
68+
var b = this.angularGrid.backendService.getCurrentSorters();
69+
var c = this.angularGrid.backendService.getCurrentPagination();
70+
var d = 0;
71+
}
72+
73+
return new Promise((resolve) => {
5074
this.dataService.getProductsByName("")
5175
.toPromise()
5276
.then(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /