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

DataSource autoSync fails to trigger Create when schema id is not "ID".

2 Answers 102 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 2
Iron
Christopher asked on 06 Jun 2017, 06:20 PM

Just ran into a wacky bug...

We have a data model where the ID field "ThisThatID" we configured a ListView with a datasource with "autoSync: true". We can read and delete fine, but when we added an item to the datasource, we noticed that the create call was never made, despite the data source showing the new item added, and it's dirty flag as false. We tried manually calling sync but to no avail.

We tried various things, but nothing seemed to work, so we took a gamble and renamed our model's ID field to simply "ID", and updated the ds config. Then boom - it worked. No changed except renaming our ID field from "ThisThanID" to "ID" in both the DS config and the actual model object.

Using the latest kendo 2017.2.

 

Sample ds config: 

{
            autoSync: true,
            transport: {
                create:{
                    type: 'POST',
                    url: App.root + 'api/blah/'
                },
                read: {
                    url: App.root + 'api/blah/'
                },
                destroy: {
                    type: 'DELETE',
                    url: App.root + 'api/blah/'
                }
            },
            schema: {
                model: {
                    id: "ThisThatID"
                }              
            }
        }

2 Answers, 1 is accepted

Sort by
0
Christopher
Top achievements
Rank 2
Iron
answered on 06 Jun 2017, 06:28 PM
Disregard, still having issues...
0
Christopher
Top achievements
Rank 2
Iron
answered on 06 Jun 2017, 06:43 PM
Ok, figured out what was going on. When we added the item to the datasource, we were specifying a value for that data item's ID. Which, rightfully, doesn't trigger a create (why create, it's already got the ID!). In our use-case, we know the ID before it is added, so our workaround was to just use a "fake" ID field on the model.
Tags
Data Source
Asked by
Christopher
Top achievements
Rank 2
Iron
Answers by
Christopher
Top achievements
Rank 2
Iron
Share this question
or