After successfully creating a kendo.data.dataSource, I managed to bind it to the KendoUI Grid on my page.
However, when attempting dataSource.insert(0, [a : "b"]);
, it surprisingly removes the existing data.
The code snippet that illustrates this issue is as follows:
var tempSource = new kendo.data.DataSource({
data: [{"ID":1,"Name":"Cliente 1","NameID":"1 - Cliente 1"},{"ID":2,"Name":"Cliente 2","NameID":"2 - Cliente 2"}]
});
This is how I linked the grid:
$("#association-grid").kendoGrid({
height: 99,
columns:
[
{
field: "ID",
title: "ID"
},
{
field: "Name",
title: "Name"
},
{
field: "NameID",
title: "NameID"
}
],
dataSource: tempSource
});
To add a new item, I used the following code:
tempSource.insert(0, { ID: "John Smith", Name: "Product Description", NameID: "123 1st Street" });
Performing the add before binding the data to the Grid results in loss of the original two items from the dataSource object.
To summarize: I have a pre-existing dataSource bound to a Grid. My goal is to insert a new item into the dataSource and then refresh the Grid for the new item to reflect.
Thank you,
VRC