We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Data Binding Issue

Thread ID:

Created:

Updated:

Platform:

Replies:

143958 Apr 11,2019 05:17 PM UTC Nov 7,2019 11:46 AM UTC Angular - EJ 2 3
loading
Tags: Schedule
Deepak
Asked On April 11, 2019 05:17 PM UTC

Hi,
I am working on syncfusion scheduler and I tried to bind data in different ways as they are mentioned in documentation.

I have followed the all steps for data binding ,tried my hand with different adaptors, also passed the same  properties as passed by syncfusion apis. But I am still unable to bind data.
 
Using asp.net core for apis and angular 7 with mongodb database.

Thanks
Deepak sharma

Nevitha Ravi [Syncfusion]
Replied On April 15, 2019 12:28 PM UTC

Hi Deepak, 
 
Greetings from Syncfusion Support. 
  
We can bind the data to Scheduler from MongoDB  and we have prepared a sample for your reference which can be downloaded from the following location. 
  
  
In the above sample, we have added CRUD actions code snippet in server.js. 
MongoClient.connect(url, function (err, db) { 
    if (err) throw err; 
    var dbo = db.db("mydb"); 
    app.use(function (req, res, next) { 
        res.header("Access-Control-Allow-Origin", "*"); 
        res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 
        next(); 
    }); 
    app.post("/GetData", (req, res) => { 
        dbo.collection('ScheduleData').find({}).toArray((err, cus) => { 
            res.send(cus); 
        }); 
    }); 
    app.post("/BatchData", (req, res) => { 
        console.log(req.body); 
        var eventData = []; 
        if (req.body.action == "insert" || (req.body.action == "batch" && req.body.added.length > 0)) { 
            (req.body.action == "insert") ? eventData.push(req.body.value) : eventData = req.body.added; 
            for (var i = 0; i < eventData.length; i++) { 
                var sdate = new Date(eventData[i].StartTime); 
                var edate = new Date(eventData[i].EndTime); 
                eventData[i].StartTime = (new Date(+sdate - (sdate.getTimezoneOffset() * 60000))); 
                eventData[i].EndTime = (new Date(+edate - (edate.getTimezoneOffset() * 60000))); 
                dbo.collection('ScheduleData').insertOne(eventData[i]); 
            } 
        } 
        if (req.body.action == "update" || (req.body.action == "batch" && req.body.changed.length > 0)) { 
            (req.body.action == "update") ? eventData.push(req.body.value) : eventData = req.body.changed; 
            for (var i = 0; i < eventData.length; i++) { 
                delete eventData[i]._id; 
                var sdate = new Date(eventData[i].StartTime); 
                var edate = new Date(eventData[i].EndTime); 
                eventData[i].StartTime = (new Date(+sdate - (sdate.getTimezoneOffset() * 60000))); 
                eventData[i].EndTime = (new Date(+edate - (edate.getTimezoneOffset() * 60000))); 
                dbo.collection('ScheduleData').updateOne({ "Id": eventData[i].Id }, { $set: eventData[i] }); 
            } 
        } 
        if (req.body.action == "remove" || (req.body.action == "batch" && req.body.deleted.length > 0)) { 
            (req.body.action == "remove") ? eventData.push({ Id: req.body.key }) : eventData = req.body.deleted; 
            for (var i = 0; i < eventData.length; i++) { 
                dbo.collection('ScheduleData').deleteOne({ "Id": eventData[i].Id }); 
            } 
        } 
        res.send(req.body); 
    }); 
}); 
 
 
Note: We have removed the local offset time before inserting and updating the events in the database collection to render the appointments without considering system UTC in the scheduler. 
  
In the below code we have given the GetData and BatchData url path to initial fetching and for performing CRUD actions using UrlAdaptor and assigned it to the scheduler datasource. 
    private dataManager: DataManager = new DataManager({ 
    url: 'http://localhost:5000/GetData', 
    crudUrl: 'http://localhost:5000/BatchData', 
    adaptor: new UrlAdaptor, 
    crossDomain: true 
  }); 
  public eventSettings: EventSettingsModel = { dataSource: this.dataManager }; 
 
Steps to run the sample: 
  1. Run MongoDB and create the collection named ‘ScheduleData’ in ‘mydb’ database.
  2. Run the below comments.
npm install 
npm run server 
npm start 
  
Please try the above sample and let us know if you need further assistance. 
  
Regards, 
Nevitha. 


Youssef Lakdime
Replied On November 5, 2019 09:27 PM UTC

Hi Navitha,

Whenever I save an appointment, right now only the startTime and the endTime are being sent to the Database. How can I make sure that also the other fields are being submitted, like subject / description / some custom fields that I made, like 'relative'.

I have modified the above function a bit , but the subject and description are still not being sent to the DB. Can you help me out?

Thanks in advance

this is my code:


app.post("/BatchData", (req, res) => {
console.log(req.body);
var eventData = [];
if (req.body.action == "insert" || (req.body.action == "batch" && req.body.added.length > 0)) {
(req.body.action == "insert") ? eventData.push(req.body.value) : eventData = req.body.added;
for (var i = 0; i < eventData.length; i++) {
var sdate = new Date(eventData[i].StartTime);
var edate = new Date(eventData[i].EndTime);
eventData[i].Subject = eventData[i].Subject;
eventData[i].Description = eventData[i].Description;
eventData[i].StartTime = (new Date(+sdate - (sdate.getTimezoneOffset() * 60000)));
eventData[i].EndTime = (new Date(+edate - (edate.getTimezoneOffset() * 60000)));
//how can I add the other fields here;
        }
}


Vinitha Devi Murugan [Syncfusion]
Replied On November 7, 2019 11:46 AM UTC

Hi Deepak, 
 
Thanks for you update. 
 
We have checked the reported case with our previously provided sample but all fields are properly send to the database at our end and for the same we have prepared the video demo for your reference with below sample. 
 
 
Screenshot:  
 
 
Kindly try the sample and if still issue persists, try to reproduce the issue in the above sample to proceed further. 
 
Regards, 
M.Vinitha devi    
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon