This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcolumn-spanning.tsx
More file actions
133 lines (132 loc) · 7.26 KB
/
column-spanning.tsx
File metadata and controls
133 lines (132 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { GridComponent, ColumnsDirective, ColumnDirective, Inject, QueryCellInfoEventArgs } from '@syncfusion/ej2-react-grids';
import { columnSpanData, ColumnSpanDataType } from './data';
import { SampleBase } from '../common/sample-base';
export class ColumnSpanning extends SampleBase<{}, {}> {
public queryCellInfoEvent = (args: QueryCellInfoEventArgs) => {
let data: ColumnSpanDataType = args.data as ColumnSpanDataType;
switch (data.EmployeeID) {
case 10001:
if (args.column.field === '9:00' || args.column.field === '2:30' || args.column.field === '4:30') {
args.colSpan = 2;
} else if (args.column.field === '11:00') {
args.colSpan = 3;
}
break;
case 10002:
if (args.column.field === '9:30' || args.column.field === '2:30' ||
args.column.field === '4:30') {
args.colSpan = 3;
} else if (args.column.field === '11:00') {
args.colSpan = 4;
}
break;
case 10003:
if (args.column.field === '9:00' || args.column.field === '11:30') {
args.colSpan = 3;
} else if (args.column.field === '10:30' || args.column.field === '3:30' ||
args.column.field === '4:30' || args.column.field === '2:30') {
args.colSpan = 2;
}
break;
case 10004:
if (args.column.field === '9:00') {
args.colSpan = 3;
} else if (args.column.field === '11:00') {
args.colSpan = 4;
} else if (args.column.field === '4:00' || args.column.field === '2:30') {
args.colSpan = 2;
}
break;
case 10005:
if (args.column.field === '9:00') {
args.colSpan = 4;
} else if (args.column.field === '11:30') {
args.colSpan = 3;
} else if (args.column.field === '3:30' || args.column.field === '4:30' || args.column.field === '2:30') {
args.colSpan = 2;
}
break;
case 10006:
if (args.column.field === '9:00' || args.column.field === '4:30' ||
args.column.field === '2:30' || args.column.field === '3:30') {
args.colSpan = 2;
} else if (args.column.field === '10:00' || args.column.field === '11:30') {
args.colSpan = 3;
}
break;
case 10007:
if (args.column.field === '9:00' || args.column.field === '3:00' || args.column.field === '10:30') {
args.colSpan = 2;
} else if (args.column.field === '11:30' || args.column.field === '4:00') {
args.colSpan = 3;
}
break;
case 10008:
if (args.column.field === '9:00' || args.column.field === '10:30' || args.column.field === '2:30') {
args.colSpan = 3;
} else if (args.column.field === '4:00') {
args.colSpan = 2;
}
break;
case 10009:
if (args.column.field === '9:00' || args.column.field === '11:30') {
args.colSpan = 3;
} else if (args.column.field === '4:30' || args.column.field === '2:30') {
args.colSpan = 2;
}
break;
case 100010:
if (args.column.field === '9:00' || args.column.field === '2:30' ||
args.column.field === '4:00' || args.column.field === '11:30') {
args.colSpan = 3;
} else if (args.column.field === '10:30') {
args.colSpan = 2;
}
break;
}
};
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={columnSpanData} queryCellInfo={this.queryCellInfoEvent.bind(this)} allowTextWrap={true} height='auto' width='auto' gridLines='Both' >
<ColumnsDirective>
<ColumnDirective field='EmployeeID' headerText='Employee ID' width='150' isPrimaryKey={true} textAlign='Right'></ColumnDirective>
<ColumnDirective field='EmployeeName' headerText='Employee Name' width='200' ></ColumnDirective>
<ColumnDirective field='9:00' headerText='9:00 AM' width='120'></ColumnDirective>
<ColumnDirective field='9:30' headerText='9:30 AM' width='120'></ColumnDirective>
<ColumnDirective field='10:00' headerText='10:00 AM' width='120'></ColumnDirective>
<ColumnDirective field='10:30' headerText='10:30 AM' width='120'></ColumnDirective>
<ColumnDirective field='11:00' headerText='11:00 AM' width='120'></ColumnDirective>
<ColumnDirective field='11:30' headerText='11:30 AM' width='120'></ColumnDirective>
<ColumnDirective field='12:00' headerText='12:00 PM' width='120'></ColumnDirective>
<ColumnDirective field='12:30' headerText='12:30 PM' width='120'></ColumnDirective>
<ColumnDirective field='2:30' headerText='2:30 PM' width='120'></ColumnDirective>
<ColumnDirective field='3:00' headerText='3:00 PM' width='120'></ColumnDirective>
<ColumnDirective field='3:30' headerText='3:30 PM' width='120'></ColumnDirective>
<ColumnDirective field='4:00' headerText='4:00 PM' width='120'></ColumnDirective>
<ColumnDirective field='4:30' headerText='4:30 PM' width='120'></ColumnDirective>
<ColumnDirective field='5:00' headerText='5:00 PM' width='120'></ColumnDirective>
</ColumnsDirective>
</GridComponent>
</div>
<div id="action-description">
<p>This sample demonstrates the Grid component with the column spanning feature. In this sample, we have spanned multiple
adjacent cells together.
</p>
</div>
<div id="description">
<p>
Grid allows to span the multiple adjacent cells. In <a href='http://ej2.syncfusion.com/react/documentation/grid/api-queryCellInfoEventArgs.html'><code>QueryCellInfo</code></a> event, you can define the <code>colSpan</code> attribute to span the cells.
</p>
<p>
In this demo, Employee <b>Davolio</b> doing analysis from 9.00 AM to 10.00 AM, so that the cells have been spanned and
Employee <b>Buchamann</b> doing support work from 9.30 AM to 11.00 AM, so that the cells have been spanned.
</p>
</div>
</div>
)
}
}