Skip to content

Commit 4c01d22

Browse files
committed
972599: To resolve Git Dependabot alerts
1 parent 42142ba commit 4c01d22

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

src/index.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,47 @@ import {
1717
} from '@syncfusion/ej2-react-schedule';
1818
import { SampleBase } from './sample-base';
1919
import axios from 'axios';
20-
import dataSource from './datasource.json';
2120
/**
2221
* Schedule Default sample
2322
*/
24-
export class Default extends SampleBase {
25-
constructor() {
26-
super(...arguments);
27-
this.data = dataSource.scheduleData;
28-
}
23+
export class Default extends SampleBase {
24+
constructor() {
25+
super(...arguments);
26+
this.flag = true;
27+
}
2928

3029
onBound(args) {
31-
// Data is already loaded from local datasource.json
30+
if (this.flag) {
31+
axios.get('http://localhost:54738/Home/GetData').then(response => {
32+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
33+
schObj.eventSettings.dataSource = response.data;
34+
});
35+
this.flag = false;
36+
}
3237
}
3338

3439
onBegin(args) {
3540
if (args.requestType === 'eventCreate') {
36-
// Handle local data creation
37-
const newEvent = args.data[0];
38-
newEvent.Id = this.data.length + 1;
39-
this.data.push(newEvent);
40-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
41-
schObj.eventSettings.dataSource = [...this.data];
41+
axios
42+
.post('http://localhost:54738/Home/Insert', args.data[0])
43+
.then(response => {
44+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
45+
schObj.eventSettings.dataSource = response.data;
46+
});
4247
} else if (args.requestType === 'eventChange') {
43-
// Handle local data update
44-
const updatedEvent = args.data;
45-
const index = this.data.findIndex(event => event.Id === updatedEvent.Id);
46-
if (index !== -1) {
47-
this.data[index] = updatedEvent;
48-
}
49-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
50-
schObj.eventSettings.dataSource = [...this.data];
48+
axios
49+
.post('http://localhost:54738/Home/Update', args.data)
50+
.then(response => {
51+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
52+
schObj.eventSettings.dataSource = response.data;
53+
});
5154
} else if (args.requestType === 'eventRemove') {
52-
// Handle local data deletion
53-
const deletedEvent = args.data[0];
54-
this.data = this.data.filter(event => event.Id !== deletedEvent.Id);
55-
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
56-
schObj.eventSettings.dataSource = [...this.data];
55+
axios
56+
.post('http://localhost:54738/Home/Delete', args.data[0])
57+
.then(response => {
58+
var schObj = document.querySelector('.e-schedule').ej2_instances[0];
59+
schObj.eventSettings.dataSource = response.data;
60+
});
5761
}
5862
}
5963
render() {
@@ -66,7 +70,6 @@ export class Default extends SampleBase {
6670
ref={schedule => (this.scheduleObj = schedule)}
6771
currentView="Month"
6872
selectedDate={new Date(2020, 5, 10)}
69-
eventSettings={{ dataSource: this.data }}
7073
dataBound={this.onBound.bind(this)}
7174
actionBegin={this.onBegin.bind(this)}
7275
>

0 commit comments

Comments
 (0)