I have a KendoUI grid which I'm using with MVVM bindings. I also have a UI where a user can enter data and select an Add button. Upon pressing the add button the new data is added to the model. The grid is set to Autosync.
The problem I have is that once a new item is added I get an error "[object Object] has no method isNew"
My grid is as follows:
$("#objJoinGrid").kendoGrid({
dataSource: {
transport: {
create: function (operation) {
operation.success();
},
update: function (operation) {
operation.success();
},
destroy: function (operation) {
operation.success();
},
read: function (operation) {
operation.success(datasetMetaModel.joinList.ObjectList);
}
},
schema: {
model: {
id: "JOIN_OBJECT_ID",
fields: {
JOIN_OBJECT_ID: { type: "number" },
JOIN_OBJECT_NAME: { type: "string" }
}
}
},
autoSync: true
},
height: 220,
columns: [
{ field: "JOIN_OBJECT_ID", width: "130px" },
{ field: "JOIN_OBJECT_NAME", width: "130px" }
]
});
I then bind my model to the grid:
datasetMetaModel = kendo.observable({
joinList: datasetModel.JoinStructure,
});
kendo.bind($("#areaDiv"), datasetMetaModel);
And in the click event of the Add button:
$("#addDataset").bind("click", function () {
var dropdownlistPO = $("#objectListing").data("kendoDropDownList");
datasetMetaModel.joinList.ObjectList.push({
JOIN_OBJECT_ID: dropdownlistPO.value(),
JOIN_OBJECT_NAME: dropdownlistPO.text()
});
});
In this instance datasetModel.JoinStructure is an empty array which comes from the server. The odd thing is that if I actually add one entry to the server then everything works, I can add new items without issue. Any ideas? I'm guessing it's something to do with how I'm adding the new item.