我正在尝试将新项目插入到现有的kendo ui表中,但我没有显示任何内容。 DataSource从ajax请求中收费。这里是我的剑道ui表的定义
var baseUrl = '/SMART/api/Build/GetAll';
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: baseUrl,
dataType: "json",
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return {
models: kendo.stringify(options.models)
};
}
}
},
batch: true,
pageSize: 15
});
$("#listGrid").kendoGrid({
dataSource: dataSource,
pageable: true,
reorderable: true,
resizable: true,
sortable: true,
filterable: {
mode: "row"
},
columns: [
{
filterable: {
cell: {
enabled: true,
showOperators: false,
operator: "contains"
}
},
field: "Name",
title: "Name"
},
{
filterable: {
cell: {
enabled: true,
showOperators: false,
operator: "contains"
}
},
field: "Type",
title: "Type"
},{
filterable: {
cell: {
enabled: true,
showOperators: false,
operator: "contains"
}
},
field: "ToBeDisplayed",
title: "To be displayed",
template: "<input name='ToBeDisplayed' type='checkbox' data-bind='checked: ToBeDisplayed' #= ToBeDisplayed ? checked='checked' : '' # class='build-tobedisplayed-checkbox'/>"
},
]
})
以下是插入代码
var grid = $("#listGrid").data("kendoGrid");
grid.dataSource.insert({ Name: "6.03", Type: "WIP", ToBeDisplayed: true });
答案 0 :(得分:0)
问题很简单。
insert
命令还需要索引位置作为插入的一部分,即:
:此强>
grid.dataSource.insert({ Name: "6.03", Type: "WIP", ToBeDisplayed: true });
将
grid.dataSource.insert(1,{ Name: "6.03", Type: "WIP", ToBeDisplayed: true });
根据文档链接。 datasource insert
如果要将新项添加到数据源集合,请改用add
方法。