Error trying to sync to remote datasource

5 posts, 0 answers
  1. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Aug 2012 Link to this post

    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. 
  2. Jesper
    Jesper avatar
    25 posts
    Member since:
    Jun 2012

    Posted 14 Aug 2012 Link to this post

    Have you confirmed that a request is sent?
    Can you post it here? 
    Have you checked your server logs?
  3. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 14 Aug 2012 Link to this post

    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.
  4. Jesper
    Jesper avatar
    25 posts
    Member since:
    Jun 2012

    Posted 14 Aug 2012 Link to this post

    Can you post a JSFiddle example of the problem?

    http://jsfiddle.net/ 
  5. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 14 Aug 2012 Link to this post

    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??
Back to Top