This is a migrated thread and some comments may be shown as answers.

Error trying to sync to remote datasource

4 Answers 253 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Devon
Top achievements
Rank 1
Devon asked on 13 Aug 2012, 02:22 PM
I'm trying to sync changes to my remote datasource but it's only changing them locally. 

Here's my code:

Datasource:

var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "http://localhost:8080/databases/shipping/docs",
                    dataType: "json",
                    data: {
                        q: "javascript"
                    }
                },
                update: {
                    url: "http://localhost:8080/databases/shipping/docs",
                    dataType: "json"
                }
            },
            schema: {
                model: {
                    id: "id",
                    fields: {
                        Name: { type: "string" },
                        Telephone: { type: "string" },
                        Address: { type: "string" },
                        Suburb: { type: "string" },
                        City: { type: "string" },
                        Province: { type: "string" },
                        Country: { type: "string" },
                        PostalCode: { type: "string" },
                        DeliveryStatus: { type: "string" },
                        Packages: { type: "auto" }
                    }
                }
            }
        });

"Save Changes" Button Click: It might be a bit messy because I've been trying loads of different techniques

var packageId;
 
        function saveChanges(e) {
            var button = e.button,
                item = packageDataSource.get(button.data("itemId"));
            packageId = item.ID;
             
            dataSource.fetch(function () {
                var packageToUpdate = dataSource.data()[id].Packages[packageId];
                packageToUpdate.Status = "Delivered";
                dataSource.sync();
                console.log(dataSource);
            });
        }

I can see the changes reflecting in my console when I check the console.log(dataSource); after the dataSource.sync(); but when I check my remote database there's no change. 

4 Answers, 1 is accepted

Sort by
0
Jesper
Top achievements
Rank 1
answered on 14 Aug 2012, 05:39 AM
Have you confirmed that a request is sent?
Can you post it here? 
Have you checked your server logs?
0
Devon
Top achievements
Rank 1
answered on 14 Aug 2012, 05:53 AM
I can't see any record of the request being sent. 

When I request the data from the database initially I can see the request in fiddler but not when I try sync.
0
Jesper
Top achievements
Rank 1
answered on 14 Aug 2012, 06:01 AM
Can you post a JSFiddle example of the problem?

http://jsfiddle.net/ 
0
Devon
Top achievements
Rank 1
answered on 14 Aug 2012, 06:19 AM
Unfortunately I have no experience with jsfiddle so I'm struggling to adapt my code to it. 

I have attached a copy of my code here for you. Will that help??
Tags
Data Source
Asked by
Devon
Top achievements
Rank 1
Answers by
Jesper
Top achievements
Rank 1
Devon
Top achievements
Rank 1
Share this question
or