Hello,
I'm trying to implement the Schedule component in my web app using Nodejs, React, and Supabase as my database. I've binded the ScheduleComponent data to my database. Now I want to overwrite the insert/delete/edit operations so that they work with my database not just local data. It works, but I keep getting a weird runtime error that I can't figure out how to fix. Here's my code. What should I do differently?
Hi Victoria,
Based on the details provided, we have attempted to create a runnable sample, but we are encountering difficulties understanding the issues you are facing on your end. Providing more information about the specific problems you're encountering will greatly assist us in understanding and resolving the issue effectively. Please share any error messages, unexpected behaviors, or specific challenges you are encountering so that we can better assist you.
Additionally, we suggest implementing event
insertion, deletion, and editing functionalities with remote database CRUD
operations using the DataManager. Below, we have provided sample code
along with attached User Guide documentation and forum links for your
reference. Please give it a try, and feel free to reach out if you need any
further assistance.
Sample: https://stackblitz.com/edit/react-front-end-sample-chasmr?file=index.js
UG:
https://ej2.syncfusion.com/react/documentation/data/getting-started
https://ej2.syncfusion.com/react/documentation/schedule/data-binding#scheduler-crud-actions
Forum:
https://forumassist.syncfusion.com/178606
https://forumassist.syncfusion.com/178161
Service: https://www.syncfusion.com/downloads/support/forum/170725/ze/ScheduleCRUD1166139915
Regards,
Ashok
Hello,
I'll share more about the current strategy I used to implement this. I bind the Schedule component to a variable `events`. This variable is empty at first but when the page loads we make an API call to our database to get all relevant events. Then these events are reformatted to match Syncfusion's expected structure for an event object. This all works great.
Then, as you can see from the code I already shared I overwrote the delete and edit actions. They are executed as expected. However, the Schedule component throws a Runtime error. When I edit an event and click on the save button, it is in fact edited as expected but this error is thrown and the edit popup remains open:
Uncaught TypeError: e.replace is not a function
at T (265-2af8373500626118.js:1:12848)
at t.update (265-2af8373500626118.js:1:208708)
at t.batchRequest (265-2af8373500626118.js:1:206623)
at e.saveChanges (265-2af8373500626118.js:1:251007)
at e.<anonymous> (265-2af8373500626118.js:1:1044478)
at e.notify (265-2af8373500626118.js:1:45267)
at t.trigger (265-2af8373500626118.js:1:393781)
at e.saveEvent (265-2af8373500626118.js:1:1043983)
at t.saveEvent (265-2af8373500626118.js:1:1138395)
at e.processCrudActions (265-2af8373500626118.js:1:1003145)
How can I prevent this error or just force close the edit popup menu?
Analogously, when I delete an event it all works. And the popup is closed which is great. But there is another runtime error:
Uncaught TypeError: e.indexOf is not a function
at e.getObject (265-2af8373500626118.js:1:265847)
at t.remove (265-2af8373500626118.js:1:208512)
at t.batchRequest (265-2af8373500626118.js:1:206680)
at e.saveChanges (265-2af8373500626118.js:1:251007)
at e.<anonymous> (265-2af8373500626118.js:1:1053219)
at e.notify (265-2af8373500626118.js:1:45267)
at t.trigger (265-2af8373500626118.js:1:393781)
at e.processDelete (265-2af8373500626118.js:1:1052338)
at e.deleteEvent (265-2af8373500626118.js:1:1045330)
at e.dialogButtonClick (265-2af8373500626118.js:1:701859)
What are the steps to apply the data manager. I have a database where we store all events. To get the relevant events we call this endpoint:
Step 1: Create DataManager. Should we create it like this:
Step 2: Store the events in our database with Syncfusion's structure for an event object.
Is that right? Should our database events have the same fields as the event object that the Schedule Component expects? If so, what are they?
Are there any other steps after that? The documentation is confusing. There isn't a straightforward tutorial that explains all the steps and how to properly connect to a database to simply feed into the schedule component.
Hello,
I'll share more about the current strategy I used to implement this. I bind the Schedule component to a variable `events`. This variable is empty at first but when the page loads we make an API call to our database to get all relevant events. Then these events are reformatted to match Syncfusion's expected structure for an event object. This all works great.
Then, as you can see from the code I already shared I overwrote the delete and edit actions. They are executed as expected. However, the Schedule component throws a Runtime error. When I edit an event and click on the save button, it is in fact edited as expected but this error is thrown and the edit popup remains open:
Uncaught TypeError: e.replace is not a function
at T (265-2af8373500626118.js:1:12848)
at t.update (265-2af8373500626118.js:1:208708)
at t.batchRequest (265-2af8373500626118.js:1:206623)
at e.saveChanges (265-2af8373500626118.js:1:251007)
at e.<anonymous> (265-2af8373500626118.js:1:1044478)
at e.notify (265-2af8373500626118.js:1:45267)
at t.trigger (265-2af8373500626118.js:1:393781)
at e.saveEvent (265-2af8373500626118.js:1:1043983)
at t.saveEvent (265-2af8373500626118.js:1:1138395)
at e.processCrudActions (265-2af8373500626118.js:1:1003145)
How can I prevent this error or just force close the edit popup menu?
Analogously, when I delete an event it all works. And the popup is closed which is great. But there is another runtime error:
Uncaught TypeError: e.indexOf is not a function
at e.getObject (265-2af8373500626118.js:1:265847)
at t.remove (265-2af8373500626118.js:1:208512)
at t.batchRequest (265-2af8373500626118.js:1:206680)
at e.saveChanges (265-2af8373500626118.js:1:251007)
at e.<anonymous> (265-2af8373500626118.js:1:1053219)
at e.notify (265-2af8373500626118.js:1:45267)
at t.trigger (265-2af8373500626118.js:1:393781)
at e.processDelete (265-2af8373500626118.js:1:1052338)
at e.deleteEvent (265-2af8373500626118.js:1:1045330)
at e.dialogButtonClick (265-2af8373500626118.js:1:701859)
What are the steps to apply the data manager. I have a database where we store all events. To get the relevant events we call this endpoint:
Step 1: Create DataManager. Should we create it like this:
Step 2: Store the events in our database with Syncfusion's structure for an event object.
Is that right? Should our database events have the same fields as the event object that the Schedule Component expects? If so, what are they?
Are there any other steps after that? The documentation is confusing. There isn't a straightforward tutorial that explains all the steps and how to properly connect to a database to simply feed into the schedule component.
Hi Victoria,
Query 1: How can I prevent this error or just force close the edit popup menu?
We suspect that the CRUD actions for the schedule are not properly completed, and the API calls at your end may be causing the runtime errors you are experiencing during edit and delete events. Therefore, we suggest using the DataManager to render events with insert, update, and delete operations as expected.
Query 2: What are the steps to apply the data manager. I have a database where we store all events. To get the relevant events we call this endpoint:
UrlAdoptor() will be binding, likely to access or
retrieve data from an external source. storing events in an object, which
allows for easier manipulation and management of the data. It also mentions the
importance of defining field mappings, which establish the relationship between
fields in the data source and the scheduler component, ensuring proper display
and functionality. Refer the below shared documentation.
Field mapping documentation: https://ej2.syncfusion.com/react/documentation/schedule/appointments#built-in-fields
Query 3: Create DataManager and Store the events in our database with Syncfusion's structure for an event object.
We suggest using the crudURL property in the DataManager. When you insert, edit, or remove an event, a POST request will be sent to the crudURL. In that http request you can get all added, changed and deleted event details as shown in the below shared code snippet. By using that you can modify your database. Refer the shared sample.
|
const [dataManager, setDataManager] = useState(new DataManager({ url: `http://localhost:54738/Home/LoadData?view=${this.id}`, crudUrl: 'http://localhost:54738/Home/UpdateData', crossDomain: true, adaptor: new UrlAdaptor(), })); const fieldsData = { id: { name: 'Id' }, subject: { name: 'Subject' }, location: { name: 'Location' }, description: { name: 'Description' }, startTime: { name: 'StartTime' }, endTime: { name: 'EndTime' } }; |
Sample: https://stackblitz.com/edit/react-enf4ba-wn22t8?file=index.js
Please get back to us with the required details for further assistance.
Regards,
Vijay