Skip to content

Commit 6474c33

Browse files
Integrated latest changes at 06-07-2024 7:30:21 PM
1 parent 1f8d434 commit 6474c33

File tree

41 files changed

+45108
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+45108
-582
lines changed

ej2-react-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2623,7 +2623,7 @@
26232623
<li><a href="https://ej2.syncfusion.com/react/documentation/api/tooltip/">API Reference</a></li>
26242624
</ul>
26252625
</li><li>
2626-
TreeGrid
2626+
<a href="/ej2-react/treegrid/overview">TreeGrid</a>
26272627
<ul>
26282628
<li>Getting Started
26292629
<ul>

ej2-react/3d-chart/getting-started.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ To get started quickly with React 3D Charts, you can check on this video:
1717

1818
{% youtube "https://www.youtube.com/watch?v=S3SPJYF4Fw8" %}
1919

20-
2120
## Dependencies
2221

2322
Below is the list of minimum dependencies required to use the 3D Chart component.
@@ -66,8 +65,7 @@ To install `create-react-app` run the following command.
6665

6766
## Add 3D Chart to the project
6867

69-
Now, you can start adding 3D Chart component in the application.
70-
For getting started, add the 3D Chart component in `src/App` file using following code.
68+
Now, you can start adding 3D Chart component in the application. For getting started, add the 3D Chart component in `src/App` file using following code.
7169

7270
{% tabs %}
7371
{% highlight js tabtitle="index.jsx" %}

ej2-react/code-snippet/pivot-table/default-cs299/app/index.jsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% raw %}
21
import * as React from 'react';
32
import * as ReactDOM from 'react-dom';
43
import { PivotViewComponent } from '@syncfusion/ej2-react-pivotview';
@@ -30,33 +29,33 @@ function App() {
3029
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }]
3130
};
3231
let pivotObj;
33-
function ondataBound(args) {
34-
var dataSource = JSON.parse(pivotObj.getPersistData()).dataSourceSettings.dataSource;
35-
var a = document.getElementById('save');
36-
var mime_type = 'application/octet-stream'; // text/html, image/png, et c
32+
function ondataBound() {
33+
const dataSource = JSON.parse(pivotObj.getPersistData()).dataSourceSettings.dataSource;
34+
const a = document.getElementById('save');
35+
const mime_type = 'application/octet-stream'; // text/html, image/png, et c
3736
a.setAttribute('download', 'pivot.JSON');
3837
a.href = 'data:' + mime_type + ';base64,' + btoa(JSON.stringify(dataSource) || '');
3938
document.getElementById('files').addEventListener('change', readBlob, false);
4039
}
41-
function readBlob(args) {
42-
var files = document.getElementById('load').files;
43-
var file = files[0];
44-
var start = 0;
45-
var stop = file.size - 1;
46-
var reader = new FileReader();
40+
function readBlob() {
41+
const files = document.getElementById('files').files;
42+
const file = files[0];
43+
const start = 0;
44+
const stop = file.size - 1;
45+
const reader = new FileReader();
4746
reader.onloadend = function (evt) {
4847
if (evt.target.readyState == FileReader.DONE) {
49-
pivotObj.dataSource = JSON.parse(evt.target.result);
48+
pivotObj.dataSourceSettings = JSON.parse(evt.target.result);
5049
}
5150
};
52-
var blob = file.slice(start, stop + 1);
51+
const blob = file.slice(start, stop + 1);
5352
reader.readAsBinaryString(blob);
53+
document.getElementById('files').value = '';
5454
}
5555
return (<div className='control-pane'>
5656
<div><style>{SAMPLE_CSS}</style><PivotViewComponent id='PivotView' ref={d => pivotObj = d} dataSourceSettings={dataSourceSettings} width={'100%'} height={350} gridSettings={{ columnWidth: 140 }} dataBound={ondataBound.bind(this)}></PivotViewComponent></div><a id="save" class="btn btn-primary">Save</a><div class="fileUpload btn btn-primary"><span>Load</span><input id="files" type="file" class="upload"/></div>
5757
</div>);
5858
}
5959
;
6060
export default App;
61-
ReactDOM.render(<App />, document.getElementById('sample'));
62-
{% endraw %}
61+
ReactDOM.render(<App />, document.getElementById('sample'));
Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
{% raw %}
2-
3-
41
import * as React from 'react';
52
import * as ReactDOM from 'react-dom';
6-
import { IDataOptions, IDataSet, Inject, PivotViewComponent } from '@syncfusion/ej2-react-pivotview';
3+
import { IDataOptions, IDataSet, PivotViewComponent } from '@syncfusion/ej2-react-pivotview';
74
import { pivotData } from './datasource';
85

96
const SAMPLE_CSS = `
@@ -25,46 +22,46 @@ const SAMPLE_CSS = `
2522
}`;
2623

2724
function App() {
28-
let dataSourceSettings: IDataOptions = {
29-
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
30-
dataSource: pivotData as IDataSet[],
31-
filters: [],
32-
formatSettings: [{ name: 'Amount', format: 'C0' }],
33-
rows: [{ name: 'Country' }, { name: 'Products' }],
34-
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }]
35-
};
36-
let pivotObj: PivotViewComponent;
25+
let dataSourceSettings: IDataOptions = {
26+
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
27+
dataSource: pivotData as IDataSet[],
28+
filters: [],
29+
formatSettings: [{ name: 'Amount', format: 'C0' }],
30+
rows: [{ name: 'Country' }, { name: 'Products' }],
31+
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }]
32+
};
33+
let pivotObj: PivotViewComponent;
3734

38-
function ondataBound(args: any): void {
39-
var dataSource = JSON.parse(pivotObj.getPersistData()).dataSourceSettings.dataSource;
40-
var a = document.getElementById('save');
41-
var mime_type = 'application/octet-stream'; // text/html, image/png, et c
35+
function ondataBound(): void {
36+
const dataSource = JSON.parse(pivotObj.getPersistData()).dataSourceSettings;
37+
const a: HTMLAnchorElement = document.getElementById('save') as HTMLAnchorElement;
38+
const mime_type = 'application/octet-stream'; // text/html, image/png, et c
4239
a.setAttribute('download', 'pivot.JSON');
43-
a.href = 'data:'+ mime_type +';base64,'+ btoa(JSON.stringify(dataSource) || '');
44-
document.getElementById('files').addEventListener('change', readBlob, false);
40+
a.href = 'data:' + mime_type + ';base64,' + btoa(JSON.stringify(dataSource) || '');
41+
(document.getElementById('files') as HTMLInputElement).addEventListener('change', readBlob, false);
4542
}
46-
function readBlob(args: any): void {
47-
var files = document.getElementById('load').files;
48-
var file = files[0];
49-
var start = 0;
50-
var stop = file.size - 1;
51-
var reader = new FileReader();
52-
reader.onloadend = function(evt) {
53-
if (evt.target.readyState == FileReader.DONE) {
54-
pivotObj.dataSource = JSON.parse(evt.target.result);
43+
44+
function readBlob(): void {
45+
const files: FileList = (document.getElementById('files') as HTMLInputElement).files as FileList;
46+
const file: File = files[0];
47+
const start: number = 0;
48+
const stop: number = file.size - 1;
49+
const reader: FileReader = new FileReader();
50+
reader.onloadend = function (evt: ProgressEvent<FileReader>) {
51+
if ((evt.target as FileReader).readyState == FileReader.DONE) {
52+
pivotObj.dataSourceSettings = JSON.parse((evt.target as FileReader).result as string);
5553
}
5654
};
57-
var blob = file.slice(start, stop + 1);
55+
const blob: Blob = file.slice(start, stop + 1);
5856
reader.readAsBinaryString(blob);
57+
(document.getElementById('files') as HTMLInputElement).value = '';
5958
}
6059

61-
return (<div className='control-pane'>
62-
<div><style>{SAMPLE_CSS}</style><PivotViewComponent id='PivotView' ref={d => pivotObj = d} dataSourceSettings={dataSourceSettings} width={'100%'} height={350} gridSettings={{ columnWidth: 140 }} dataBound={ondataBound.bind(this)}></PivotViewComponent></div><a id="save" class="btn btn-primary">Save</a><div class="fileUpload btn btn-primary"><span>Load</span><input id="files" type="file" class="upload" /></div>
63-
</div>);
60+
return (<div className='control-pane'><div><style>{SAMPLE_CSS}</style>
61+
<PivotViewComponent id='PivotView' ref={d => pivotObj = d} dataSourceSettings={dataSourceSettings} width={'100%'} height={350}
62+
gridSettings={{ columnWidth: 140 }} dataBound={ondataBound.bind(this)}></PivotViewComponent></div>
63+
<a id="save" className="btn btn-primary">Save</a><div className="fileUpload btn btn-primary"><span>Load</span><input id="files" type="file" className="upload" /></div>
64+
</div>);
6465
};
6566
export default App;
66-
ReactDOM.render(<App />, document.getElementById('sample'));
67-
68-
69-
70-
{% endraw %}
67+
ReactDOM.render(<App />, document.getElementById('sample'));
Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
1-
2-
3-
import { IDataOptions, IDataSet, PivotViewComponent, AggregateEventArgs } from '@syncfusion/ej2-react-pivotview';
1+
import { PivotViewComponent, FieldList, Inject } from '@syncfusion/ej2-react-pivotview';
2+
import { Uploader } from '@syncfusion/ej2-inputs';
43
import * as React from 'react';
54
import * as ReactDOM from 'react-dom';
6-
import { pivotData } from './datasource';
75

86
function App() {
9-
10-
let dataSourceSettings: IDataOptions = {
11-
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
12-
dataSource: pivotData as IDataSet[],
13-
expandAll: false,
14-
filters: [],
15-
drilledMembers: [{ name: 'Country', items: ['France'] }],
16-
formatSettings: [{ name: 'Amount', format: 'C2'}],
17-
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
18-
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
19-
rows: [{ name: 'Country' }, { name: 'Products' }],
20-
}
217
let pivotObj: PivotViewComponent;
8+
let input: HTMLInputElement
9+
let isInitial = true;
10+
11+
function ondataBound(): void {
12+
if (isInitial) {
13+
// Step 1: Initiate the file uploader
14+
let uploadObj: Uploader = new Uploader();
15+
uploadObj.appendTo('#fileupload');
16+
input = document.querySelector('input[type="file"]') as HTMLInputElement;
17+
// Step 2: Add the event listener which fires when the *.CSV file is uploaded.
18+
input.addEventListener('change', loadCSV, false);
19+
isInitial = false;
20+
}
21+
}
2222

23-
function aggregateCell(args: AggregateEventArgs): void {
24-
args.skipFormatting = true;
23+
function loadCSV() {
24+
// Step 3: Initiate the file reader
25+
const reader: FileReader = new FileReader();
26+
reader.onload = function () {
27+
const Result: string[][] = [];
28+
// Step 4: Getting the string output which is to be converted as string[][].
29+
let readerResult: string[] = (reader.result as string).split(/\r?\n|\r/);
30+
(Result as string[][]).push(readerResult[0].split(',').map(function (e) { return e.replace(/ /g, '').replace(/^\"(.+)\"$/, "$1"); }));
31+
for (let i: number = 1; i < readerResult.length; i++) {
32+
if (readerResult[i as number] !== '') {
33+
(Result as string[][]).push(readerResult[i as number].split(','));
34+
}
35+
}
36+
pivotObj.dataSourceSettings = {
37+
// Step 5: The string[][] result to be bound as data source
38+
dataSource: Result,
39+
type: 'CSV',
40+
// Step 6: The appropriate report needs to be provided here.
41+
};
42+
}
43+
reader.readAsText(((input as HTMLInputElement).files as FileList)[0]);
44+
input.value = '';
45+
(document.querySelector('.e-upload-files') as HTMLElement).remove();
2546
}
2647

27-
return (<PivotViewComponent ref={d => pivotObj = d} id='PivotView' height={350} aggregateCellInfo={aggregateCell.bind(this)} dataSourceSettings={dataSourceSettings}></PivotViewComponent>);
48+
return (<div className='control-pane'><input type="file" id="fileupload" />
49+
<PivotViewComponent ref={d => pivotObj = d} id='PivotView' height={350} showFieldList={true} dataBound={ondataBound.bind(this)}>
50+
<Inject services={[FieldList]} />
51+
</PivotViewComponent></div>
52+
);
2853
};
2954

3055
export default App;
31-
ReactDOM.render(<App />, document.getElementById('sample'));
32-
33-
34-
56+
ReactDOM.render(<App />, document.getElementById('sample'));

ej2-react/code-snippet/pivot-table/getting-started-cs1/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs1/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs2/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs2/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs3/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs3/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs4/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs4/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs5/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs5/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs6/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs6/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

ej2-react/code-snippet/pivot-table/getting-started-cs7/app/datasource.jsx

Lines changed: 6382 additions & 0 deletions
Large diffs are not rendered by default.

ej2-react/code-snippet/pivot-table/getting-started-cs7/systemjs.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ System.config({
5050
}
5151
},
5252
packages: {
53-
'app': { main: 'index', defaultExtension: 'tsx' },
53+
'app': { main: 'App', defaultExtension: 'tsx' },
5454
}
5555

5656
});

0 commit comments

Comments
 (0)