$scope.goods = [
{ oid: 1, name: "", count: 0, description: "" },
{ oid: 2, name: "", count: 0, description: "" },
{ oid: 3, name: "", count: 0, description: "" },
{ oid: 4, name: "", count: 0, description: "" },
];
$scope.goodsGridOptions = {
dataSource: new kendo.data.DataSource({
transport: {
read: function(options) {
options.success($scope.goods);
},
create: function(options) {
console.log(options.data);
options.success(options.data);
},
update: function(options) {
console.log(options.data);
options.success();
},
destroy: function(options) {
console.log(options.data);
options.success();
}
},
schema: {
model: {
id: "oid",
fields: {
oid: {
editable: false,
},
name: {},
count: { type: "number",},
description: {},
},
total: function(result) {
result = result.data || result;
return result.length || 0;
}
}
},
}),
sortable: true,
pageable: {
pageSize: 5,
},
editable: {
mode: "inline",
},
toolbar: [{
name: "create",
text: "新增物品",
}],
columns: [{ field: "oid", title: "序号", hidden: true, width: "20px" },
{ field: "name", title: "品种", width: "100px" },
{ field: "count", title: "数量", width: "40px" },
{ field: "description", title: "备注", width: "40px" },
{ title: "操作", width: "100px", command: [ { name: "edit" },{ name: "destroy" }] },
]
};
when add new object, the create function will be invoke, but the local data's length will no change.
and if i click add button next time, the create function will be invoke twice in one click. click again, the create function will be invoke many in one click.
how can i write the code?