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

Sync method not called on DataSource

2 Answers 174 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Cory Deppen
Top achievements
Rank 1
Cory Deppen asked on 23 Dec 2011, 04:55 AM
I have a very basic ASP.NET MVC app that has a kendoGrid and DataSource defined on a page. The read method works fine and populates the grid as expected, but I'm having issues with the create method. I've set the datasource's schema model to a model I defined and I've inspected and confirmed the model shows the new item after calling the add method on the datasource. Additionally, the new item also appears in the grid. For some reason, though, it seems when I call sync() the MVC controller method isn't called. Then when read() is called on the datasource the new item is cleared since it wasn't persisted.

Hopefully I've just missed something very simple, but I'm pretty confused why the create method doesn't seem to be called when the datasource is synced.

Any ideas?

2 Answers, 1 is accepted

Sort by
0
Cory Deppen
Top achievements
Rank 1
answered on 23 Dec 2011, 07:30 AM
In digging around, I noticed isNew() returns false for the new model. I think this may be because the id of my model is the Name field (the object doesn't have an "ID" - Name is unique). So when the new model is added and Name is assigned a value, it must recognize the "id" has a value and considers it an existing model. On the other hand, if I had an ID field that was system assigned the value would be undefined by default.

So I'm left wondering whether I'm SOL due to my data model, or if it's possible to have a model with a single field.
0
Cory Deppen
Top achievements
Rank 1
answered on 26 Dec 2011, 05:08 AM
I just added an id field to my model, changed my Kendo Model to use this new field for the id property, and now the sync method is called and the item is created as expected.
Tags
Data Source
Asked by
Cory Deppen
Top achievements
Rank 1
Answers by
Cory Deppen
Top achievements
Rank 1
Share this question
or