【发布时间】:2014-08-13 18:27:16
【问题描述】:
我正在使用带有 Angular/Breeze 的 Kendo UI。我有一个可编辑的网格,其中一列是下拉菜单。一切正常,直到保存发生。问题是我的 odata 调用正在等待:
Id(guid), Name, Description, CategoryId(guid)
当下拉菜单被改变时,它会触发一个保存命令并像这样发回:
Id(guid), Name, Description, Category(categoryId, Name, Desc)
在哪里以及如何让网格只发回 `categoryId 而不是整个类别对象?
vm.columns = [
{ field: 'name', title: 'name' },
{ field: 'desc', title: 'description' },
{
field: 'categoryId',
title: 'group',
template: getCategory,
editor: categoryDropDown
}
];
function categoryDropDown(container, options) {
$('<input data-text-field="categoryName" data-value-field="categoryId" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "categoryName",
dataValueField: "categoryId",
dataSource: vm.categories
});
}
function getCategory(item) {
for (var i = 0, length = vm.category; i < length; i++) {
console.log(vm.categories[i].categoryId);
if (vm.categories[i].categoryId === item.categoryId) {
return vm.categories[i].categoryName;
}
}
return '';
}
这是主要数据源的架构:
schema: {
model: {
id: 'Id',
fields: {
categoryName: { editable: true },
categoryDesc: { editable: true },
categoryId: { editable: true }
}
}
}
【问题讨论】:
-
在模型中尝试将类型设置为字符串 categoryId: { editable: true , type: "string" },
标签: angularjs kendo-ui kendo-grid odata breeze