Skip to content

Commit b8b23a6

Browse files
authored
feat: update column width and enable drag selection (#4394)
1 parent 2b36714 commit b8b23a6

File tree

2 files changed

+88
-64
lines changed

2 files changed

+88
-64
lines changed

examples-standalone/grid-charts-integration/src/app/components/stock-list/stock-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<kendo-grid #grid [data]="gridData" [selectable]="selectableSettings" [height]="500" [kendoGridSelectBy]="selectBy"
1212
[selectedKeys]="mySelection" (cellClick)="onCellClick($event)" (selectionChange)="onSelectionChange()">
13-
<kendo-grid-checkbox-column [showSelectAll]="true" [width]="30"></kendo-grid-checkbox-column>
13+
<kendo-grid-checkbox-column [showSelectAll]="true" [width]="35"></kendo-grid-checkbox-column>
1414

1515
<kendo-grid-column class="grid-symbol-col" field="symbol" title="Symbol" [width]="80"></kendo-grid-column>
1616
<kendo-grid-column field="name" title="Name" [width]="140"></kendo-grid-column>
Lines changed: 87 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { Component, ViewChild, ViewEncapsulation } from '@angular/core';
2-
import { ContextMenuComponent, ContextMenuSelectEvent, MenusModule } from "@progress/kendo-angular-menu";
3-
import { CellClickEvent, ExcelModule, GridComponent, GridModule, SelectableSettings } from "@progress/kendo-angular-grid";
2+
import {
3+
ContextMenuComponent,
4+
ContextMenuSelectEvent,
5+
MenusModule,
6+
} from '@progress/kendo-angular-menu';
7+
import {
8+
CellClickEvent,
9+
ExcelModule,
10+
GridComponent,
11+
GridModule,
12+
SelectableSettings,
13+
} from '@progress/kendo-angular-grid';
414
import { IconsModule } from '@progress/kendo-angular-icons';
515
import { SVGIcon, infoCircleIcon } from '@progress/kendo-svg-icons';
616
import { ChartConfig, Stock } from '../../model';
@@ -18,82 +28,96 @@ import { CommonModule } from '@angular/common';
1828
@Component({
1929
selector: 'app-stock-list',
2030
standalone: true,
21-
imports: [MenusModule, GridModule, IconsModule, NumberFormatPipe, DialogsModule, ExcelModule, WindowComponent, DayChartComponent, WindowComponent, CommonModule],
31+
imports: [
32+
MenusModule,
33+
GridModule,
34+
IconsModule,
35+
NumberFormatPipe,
36+
DialogsModule,
37+
ExcelModule,
38+
WindowComponent,
39+
DayChartComponent,
40+
WindowComponent,
41+
CommonModule,
42+
],
2243
templateUrl: './stock-list.component.html',
2344
styleUrl: './stock-list.component.scss',
24-
encapsulation: ViewEncapsulation.None
45+
encapsulation: ViewEncapsulation.None,
2546
})
2647
export class StockListComponent {
27-
@ViewChild('gridmenu') public gridContextMenu: ContextMenuComponent | undefined;
28-
@ViewChild('grid') public grid: GridComponent | undefined;
48+
@ViewChild('gridmenu') public gridContextMenu:
49+
| ContextMenuComponent
50+
| undefined;
51+
@ViewChild('grid') public grid: GridComponent | undefined;
2952

30-
public infoIcon: SVGIcon = infoCircleIcon;
53+
public infoIcon: SVGIcon = infoCircleIcon;
3154

32-
public items: object[] = menuItems;
33-
public opened = false;
34-
public chartConfiguration: ChartConfig = { seriesType: 'line', stack: false };
35-
public gridData: Stock[] = stocksInPortfolio;
36-
public selectableSettings: SelectableSettings = {
37-
checkboxOnly: false,
38-
mode: 'multiple'
39-
};
40-
public mySelection: Stock[] = stocksInPortfolio.slice(0, 4);
55+
public items: object[] = menuItems;
56+
public opened = false;
57+
public chartConfiguration: ChartConfig = { seriesType: 'line', stack: false };
58+
public gridData: Stock[] = stocksInPortfolio;
59+
public selectableSettings: SelectableSettings = {
60+
checkboxOnly: false,
61+
mode: 'multiple',
62+
drag: true,
63+
};
64+
public mySelection: Stock[] = stocksInPortfolio.slice(0, 4);
4165

42-
constructor() {
43-
this.allData = this.allData.bind(this);
44-
}
66+
constructor() {
67+
this.allData = this.allData.bind(this);
68+
}
4569

46-
public onCellClick(e: CellClickEvent): void {
47-
if (e.type === 'contextmenu') {
48-
const originalEvent = e.originalEvent;
49-
originalEvent.preventDefault();
50-
this.gridContextMenu?.show({
51-
left: originalEvent.pageX,
52-
top: originalEvent.pageY
53-
});
54-
}
70+
public onCellClick(e: CellClickEvent): void {
71+
if (e.type === 'contextmenu') {
72+
const originalEvent = e.originalEvent;
73+
originalEvent.preventDefault();
74+
this.gridContextMenu?.show({
75+
left: originalEvent.pageX,
76+
top: originalEvent.pageY,
77+
});
5578
}
79+
}
5680

57-
public selectBy(e: any) {
58-
return e.dataItem;
59-
}
81+
public selectBy(e: any) {
82+
return e.dataItem;
83+
}
6084

61-
public onSelectionChange() {
62-
if (this.opened) {
63-
setTimeout(() => {
64-
this.mySelection = [...this.mySelection];
65-
});
66-
}
85+
public onSelectionChange() {
86+
if (this.opened) {
87+
setTimeout(() => {
88+
this.mySelection = [...this.mySelection];
89+
});
6790
}
91+
}
6892

69-
public onSelect(e: ContextMenuSelectEvent): void {
70-
if (e.item.text === 'Charts' || e.item.items !== undefined) {
71-
return;
72-
}
73-
74-
if (e.item.text === 'Export Excel') {
75-
this.grid?.saveAsExcel();
76-
} else {
77-
this.chartConfiguration = {
78-
chartName: e.item.text,
79-
seriesType: getChartType(e.item.text) as SeriesType,
80-
stack: getChartStack(e.item.text)
81-
};
82-
if (!this.opened) {
83-
this.opened = true;
84-
}
85-
this.gridContextMenu?.hide();
86-
}
93+
public onSelect(e: ContextMenuSelectEvent): void {
94+
if (e.item.text === 'Charts' || e.item.items !== undefined) {
95+
return;
8796
}
8897

89-
public allData() {
90-
const result = {
91-
data: this.mySelection,
92-
};
93-
return result;
98+
if (e.item.text === 'Export Excel') {
99+
this.grid?.saveAsExcel();
100+
} else {
101+
this.chartConfiguration = {
102+
chartName: e.item.text,
103+
seriesType: getChartType(e.item.text) as SeriesType,
104+
stack: getChartStack(e.item.text),
105+
};
106+
if (!this.opened) {
107+
this.opened = true;
108+
}
109+
this.gridContextMenu?.hide();
94110
}
111+
}
95112

96-
public close() {
97-
this.opened = false;
98-
}
113+
public allData() {
114+
const result = {
115+
data: this.mySelection,
116+
};
117+
return result;
118+
}
119+
120+
public close() {
121+
this.opened = false;
122+
}
99123
}

0 commit comments

Comments
 (0)