我创建了Kendo. data. Data. 数据来源 成功, 我能够把它绑在网页上的KendoUI网格上。
但当我尝试 data source. Info:0, [a: "b"] ;
时,它会删除先前的数据。
我的例子代码如下:
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"}]
});
这就是我如何与电网连接:
$("#association-grid").kendoGrid({
height: 99,
columns:
[
{
field: "ID",
title: "ID"
},
{
field: "Name",
title: "Name"
},
{
field: "NameID",
title: "NameID"
}
],
dataSource: tempSource
});
这就是我如何增加一个新项目:
tempSource.insert(0, { ID: "John Smith", Name: "Product Description", NameID: "123 1st Street" });
如果我在将数据绑到网格之前执行添加,我就会失去最初在数据源对象上的前两个项目。
In summary: I have a pre-created dataSource binded to a Grid. I want to be able to add a new item to the dataSource, and then refresh the Grid so that the new item appears.
谢谢
VRC 甚RC