|
| 1 | +import 'igniteui-webcomponents-grids/grids/combined'; |
| 2 | +import { IgcDefaultMergeStrategy, IgcGridComponent, IgcGridMergeStrategy } from 'igniteui-webcomponents-grids/grids'; |
| 3 | +import 'igniteui-webcomponents-grids/grids/themes/light/bootstrap.css'; |
| 4 | +import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 5 | +import { defineAllComponents } from 'igniteui-webcomponents'; |
| 6 | + |
| 7 | +defineAllComponents(); |
| 8 | + |
| 9 | +import './index.css'; |
| 10 | + |
| 11 | +type RecordType = { |
| 12 | + ActionID: string; |
| 13 | + ProjectName: string; |
| 14 | + ActionName: string; |
| 15 | + Type: string; |
| 16 | + Priority: string; |
| 17 | + Status: string; |
| 18 | + Created: Date; |
| 19 | + LastEdit: Date; |
| 20 | +}; |
| 21 | + |
| 22 | +class PerProjectMergeStrategy extends IgcDefaultMergeStrategy { |
| 23 | + public comparer(prevRecord: RecordType, record: RecordType, field: string): boolean { |
| 24 | + const a = (prevRecord as any)[field]; |
| 25 | + const b = (record as any)[field]; |
| 26 | + const projA = prevRecord.ProjectName; |
| 27 | + const projB = record.ProjectName; |
| 28 | + return a === b && projA === projB; |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +export class Sample { |
| 33 | + private grid: IgcGridComponent; |
| 34 | + |
| 35 | + constructor() { |
| 36 | + this.grid = document.getElementById('grid') as IgcGridComponent; |
| 37 | + |
| 38 | + this.grid.data = this.data; |
| 39 | + (this.grid as any).mergeStrategy = new PerProjectMergeStrategy(); |
| 40 | + this.grid.cellMergeMode = 'always'; |
| 41 | + } |
| 42 | + |
| 43 | + private _data: RecordType[] | null = null; |
| 44 | + public get data(): RecordType[] { |
| 45 | + if (!this._data) { |
| 46 | + this._data = [ |
| 47 | + { ActionID: '1', ProjectName: 'IOT Switch Project', ActionName: 'Data Import', Type: 'Request', Priority: 'Low', Status: 'New', Created: new Date('2017-03-25'), LastEdit: new Date('2017-05-08') }, |
| 48 | + { ActionID: '2', ProjectName: 'IOT Switch Project', ActionName: 'Reports', Type: 'Request', Priority: 'Low', Status: 'New', Created: new Date('2017-03-14'), LastEdit: new Date('2017-03-15') }, |
| 49 | + { ActionID: '4', ProjectName: 'IOT Switch Project', ActionName: 'Multiple Settings', Type: 'Request', Priority: 'Low', Status: 'Rejected', Created: new Date('2017-04-05'), LastEdit: new Date('2017-04-30') }, |
| 50 | + { ActionID: '3', ProjectName: 'IOT Switch Project', ActionName: 'Data Archiving', Type: 'Request', Priority: 'Medium', Status: 'New', Created: new Date('2017-08-21'), LastEdit: new Date('2017-09-08') }, |
| 51 | + { ActionID: '5', ProjectName: 'IOT Switch Project', ActionName: 'Main Menu: Return Button', Type: 'Bug', Priority: 'Medium', Status: 'Fixed', Created: new Date('2017-06-17'), LastEdit: new Date('2017-07-03') }, |
| 52 | + { ActionID: '6', ProjectName: 'IOT Switch Project', ActionName: 'Auto Turn Off', Type: 'Bug', Priority: 'Medium', Status: 'New', Created: new Date('2017-04-12'), LastEdit: new Date('2017-05-27') }, |
| 53 | + { ActionID: '7', ProjectName: 'VR Device', ActionName: 'Higher DRI', Type: 'Request', Priority: 'Medium', Status: 'New', Created: new Date('2016-08-11'), LastEdit: new Date('2016-08-11') }, |
| 54 | + { ActionID: '8', ProjectName: 'VR Device', ActionName: 'Accessible Power Button', Type: 'Request', Priority: 'Medium', Status: 'New', Created: new Date('2016-07-13'), LastEdit: new Date('2016-07-14') }, |
| 55 | + { ActionID: '9', ProjectName: 'VR Device', ActionName: 'Additional options', Type: 'Request', Priority: 'High', Status: 'Rejected', Created: new Date('2016-09-02'), LastEdit: new Date('2016-09-08') }, |
| 56 | + { ActionID: '10', ProjectName: 'VR Device', ActionName: 'Data Log', Type: 'Request', Priority: 'High', Status: 'New', Created: new Date('2017-03-25'), LastEdit: new Date('2017-05-08') }, |
| 57 | + { ActionID: '12', ProjectName: 'VR Device', ActionName: 'Motion Blur', Type: 'Bug', Priority: 'High', Status: 'New', Created: new Date('2017-03-25'), LastEdit: new Date('2017-05-08') }, |
| 58 | + { ActionID: '11', ProjectName: 'VR Device', ActionName: 'Left Sensors Delay', Type: 'Bug', Priority: 'High', Status: 'Fixed', Created: new Date('2017-03-25'), LastEdit: new Date('2017-05-08') }, |
| 59 | + ]; |
| 60 | + } |
| 61 | + return this._data; |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +new Sample(); |
| 66 | + |
0 commit comments